You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为Firebase Functions Gen2 Firestore触发器设置函数级区域(不使用setGlobalOptions)

在Firebase Functions Gen2中为Cloud Firestore触发器单独设置函数级区域

对于Firebase Functions Gen2的Cloud Firestore触发器(比如onDocumentUpdated),你可以把触发器的路径和区域配置合并成一个对象,作为第一个参数传入函数,实现单独设置区域,无需依赖全局配置。

修改后的代码示例如下:

import { onDocumentUpdated, logger } from "firebase-functions/v2/firestore";

export const userupdated = onDocumentUpdated(
  { 
    document: "users/{userId}",
    region: "australia-southeast1" // 在这里设置函数级区域
  },
  () => {
    logger.info("IT WORKS!");
  },
);

逻辑和onCall函数的配置方式一致:将原本单独传入的文档路径,放到包含document字段的配置对象中,同时添加region字段指定目标区域即可。

内容的提问来源于stack exchange,提问作者TinyTiger

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 22:18:10