編寫擴充功能的 Cloud Functions

建立擴充功能時,請透過 Cloud Functions 編寫邏輯,位於 就像編寫只會用於 您自己的專案中您在 extension.yaml 檔案中宣告函式,且 使用者安裝擴充功能時,這些函式就會部署至 專案。

如要瞭解如何使用一般資訊,請參閱 Cloud Functions 說明文件 Cloud Functions

第 1 代和第 2 代 Cloud Functions

Firebase 支援這兩種格式 第 1 代和第 2 代 Cloud Functions。不過,Firebase 擴充功能目前對於雲端的世代有一些限制 函式,以用於特定觸發條件類型。因此 擴充功能包含了第 1 代和第 2 代函式。

以下各類型的觸發條件不支援函式產生功能。

特殊注意事項

  • 部分函式定義會要求您指定同樣屬於 在 extension.yaml 檔案中指定的檔案。舉例來說,Cloud Firestore 提供 document() 方法,用於指定要監控的文件模式及其 extension.yaml 中的對應宣告的 resource 欄位 會指定相同

    在這類情況下,extension.yaml 中指定的設定 檔案,而函式定義中指定的設定為 已忽略。

    常見的做法是在函式中指定已設定的值 每個模型都有其定義。相關範例 遵循這個模式

  • Cloud Functions 第 1 代 SDK 採用 functions.config() 方法, 可用於工作的 functions:config:set CLI 指令 第 1 代函式中的參數值。這項技術已在 Cloud Functions,且將完全無法運作在擴充功能中。而是改用 functions.params 模組 (建議) 或 process.env

使用 TypeScript

大部分關於自行開發擴充功能的說明文件都描述了工作流程 例如 Cloud Functions for Firebase不過,您可以改為編寫 建立函式

事實上, 官方 Firebase 擴充功能 都以 TypeScript 編寫請檢查這些額外資訊 在擴充功能中使用 TypeScript 的做法

如果您使用 TypeScript 編寫擴充功能的函式,就必須執行 請先參閱下列說明,再安裝擴充功能:

  1. 將擴充功能的函式原始碼編譯為 JavaScript。

    firebase ext:dev:init 指令 可讓你選擇 TypeScript 來編寫函式。指令 提供您完整且可安裝的擴充功能,以及針對其版本 可透過 npm run build 執行的指令碼

  2. package.json 檔案中,請務必將 main 欄位指向 產生的 JavaScript 程式碼

  3. 如要從本機來源安裝或上傳擴充功能 請先編譯 TypeScript 檔案。

支援的函式觸發條件

HTTP 觸發條件

系統會將 HTTP 觸發的函式部署至公開的 https 端點,並繼續執行 連線至端點時

請參閱 Cloud Functions 中的透過 HTTP 要求呼叫函式。 說明文件。

函式定義 (僅限第 1 代)

import { https } from "firebase-functions/v1";

export const yourFunctionName = https.onRequest(async (req, resp) => {
  // ...
});

資源宣告 (extension.yaml)

resources:
  - name: yourFunctionName
    type: firebaseextensions.v1beta.function
    properties:
      runtime: nodejs16
      httpsTrigger: {}
  - name: anotherFunction
    type: ...

可呼叫的函式

可呼叫函式與 HTTP 觸發的函式類似,但會實作 輕鬆透過用戶端程式碼呼叫

請參閱 Cloud Functions 說明文件中的「從應用程式呼叫函式」一文 。

函式定義 (僅限第 1 代)

import { https } from "firebase-functions/v1";

export const yourFunctionName = https.onCall(async (data, context) => {
  // ...
});

資源宣告 (extension.yaml)

resources:
  - name: yourFunctionName
    type: firebaseextensions.v1beta.function
    properties:
      runtime: nodejs16
      httpsTrigger: {}
  - name: anotherFunction
    type: ...

已排定的函式觸發條件

排定的函式會按照自訂時間表重複執行。

請參閱 Cloud Functions 說明文件中的排定函式一節,以便: 瞭解如何編寫排程函式

函式定義 (僅限第 1 代)

import { pubsub } from "firebase-functions/v1";

export const yourFunctionName = pubsub.schedule("every 6 hours").onRun((context) => {
  // ...
});

資源宣告 (extension.yaml)

resources:
  - name: yourFunctionName
    type: firebaseextensions.v1beta.function
    properties:
      scheduleTrigger:
        schedule: 'every 5 minutes'
  - name: anotherFunction
    type: ...

以下是 scheduleTrigger 可用的子欄位:

欄位 說明
schedule
(必填)

您希望函式執行的頻率。

這個欄位可接受使用任一語法 (換行使用) 單引號):

timeZone
(選答)

執行排程的時區。

如果您希望使用者在安裝 請在 extension.yaml 檔案中新增參數,並參照 函式的 resource 宣告中:

resources:
  - name: yourFunctionName
    type: firebaseextensions.v1beta.function
    properties:
      scheduleTrigger:
        schedule: ${SCHEDULE_FREQUENCY}
  - name: anotherFunction
    type: ...

params:
  - param: SCHEDULE_FREQUENCY
    label: Schedule
    description: How often do you want to run yourFunctionName()?
    type: string
    default: 'every 5 minutes'  # Specifying a default is optional.
    required: true

工作佇列觸發條件

工作佇列函式會在擴充功能的生命週期中觸發 事件,或使用管理控制台手動新增至擴充功能的工作佇列時 SDK 的 TaskQueue.enqueue() 方法

如需寫入相關資訊,請參閱「處理擴充功能的生命週期事件」一文 處理生命週期事件的函式

請參閱 Cloud Functions 中的使用 Cloud Tasks 將函式排入佇列 說明文件,提供有關編寫工作佇列函式的資訊。

函式定義 (僅限第 1 代)

import { tasks } from "firebase-functions/v1";

export const yourFunctionName = tasks.taskQueue().onDispatch(async (data, context) => {
  // ...
});

資源宣告 (extension.yaml)

resources:
  - name: myTaskFunction
    type: firebaseextensions.v1beta.function
    description: >-
      Perform a task when triggered by a lifecycle event
    properties:
      taskQueueTrigger: {}

taskQueueTrigger 屬性設為 {} 或選項對應 調整工作佇列的頻率限制和重試行為 (請參閱「微調工作」一節 佇列)。

如要在擴充功能的生命週期事件觸發函式,請將 含有函式名稱與選用的 lifecycleEvents 記錄 處理訊息時,此訊息會顯示在 Firebase 控制台中 系統就會開始處理

lifecycleEvents:
  onInstall:
    function: myTaskFunction
    processingMessage: Resizing your existing images
  onUpdate:
    function: myOtherTaskFunction
    processingMessage: Setting up your extension
  onConfigure:
    function: myOtherTaskFunction
    processingMessage: Setting up your extension

數據分析

收到指定 Analytics 事件時,Analytics 觸發函式就會執行 。

請參閱 Cloud Functions 說明文件中的「Google Analytics 觸發條件」一文 瞭解如何編寫 Analytics 觸發函式。

函式定義 (僅限第 1 代)

import { analytics } from "firebase-functions/v1";

export const yourFunctionName = analytics.event("event_name").onLog((event, context) => {
  // ...
});

資源宣告 (extension.yaml)

resources:
  - name: yourFunctionName
    type: firebaseextensions.v1beta.function
    properties:
      eventTrigger:
        eventType: providers/google.firebase.analytics/eventTypes/event.log
        resource: projects/${PROJECT_ID}/events/ga_event
  - name: anotherFunction
    type: ...

如果您希望使用者能設定 Analytics 事件來監聽 請在您的 extension.yaml 加入新參數 檔案,並參照函式 resource 宣告中的參數:

resources:
  - name: yourFunctionName
    type: firebaseextensions.v1beta.function
    properties:
      eventTrigger:
        eventType: providers/google.firebase.analytics/eventTypes/event.log
        resource: projects/${PROJECT_ID}/events/${EVENT_NAME}
  - name: anotherFunction
    type: ...

params:
  - param: EVENT_NAME
    label: Analytics event
    description: What event do you want to respond to?
    type: string
    default: ga_event  # Specifying a default is optional.
    required: true

驗證

建立或刪除使用者時,就會執行驗證觸發函式。

請參閱 Cloud Functions 中的「Firebase 驗證觸發條件」 。

函式定義 (僅限第 1 代)

import { auth } from "firebase-functions/v1";

export const yourFunctionName = auth.user().onCreate((user, context) => {
  // ...
});

export const yourFunctionName2 = auth.user().onDelete((user, context) => {
  // ...
});

資源宣告 (extension.yaml)

resources:
  - name: yourFunctionName
    type: firebaseextensions.v1beta.function
    properties:
      eventTrigger:
        eventType: providers/firebase.auth/eventTypes/user.create
        resource: projects/${PROJECT_ID}
  - name: anotherFunction
    type: ...

下表說明如何指定每個支援的驗證事件 類型:

Cloud Functions 事件觸發條件 eventType 說明
onCreate() providers/firebase.auth/eventTypes/user.create 已建立新使用者
onDelete() providers/firebase.auth/eventTypes/user.delete 已刪除使用者

Cloud Firestore

在建立、更新文件、 或刪除執行個體

請參閱 Cloud Functions 說明文件中的「Cloud Firestore 觸發條件」: ,瞭解如何編寫 Firestore 觸發函式。

函式定義 (僅限第 1 代)

import { firestore } from "firebase-functions/v1";

export const yourFunctionName = firestore.document("collection/{doc_id}")
  .onCreate((snapshot, context) => {
    // ...
  });

export const yourFunctionName2 = firestore.document("collection/{doc_id}")
  .onUpdate((change, context) => {
    // ...
  });

export const yourFunctionName3 = firestore.document("collection/{doc_id}")
  .onDelete((snapshot, context) => {
    // ...
  });

export const yourFunctionName4 = firestore.document("collection/{doc_id}")
  .onWrite((change, context) => {
    // onWrite triggers on creation, update, and deletion.
    // ...
  });

資源宣告 (extension.yaml)

resources:
  - name: yourFunctionName
    type: firebaseextensions.v1beta.function
    properties:
      eventTrigger:
        eventType: providers/cloud.firestore/eventTypes/document.write
        resource: projects/${PROJECT_ID}/databases/(default)/documents/collection/{documentID}
  - name: anotherFunction
    type: ...

下表說明如何指定各支援的 Cloud Firestore 事件類型:

Cloud Functions 事件觸發條件 eventType 說明
onCreate() providers/cloud.firestore/eventTypes/document.create 已建立新文件
onDelete() providers/cloud.firestore/eventTypes/document.delete 文件已刪除
onUpdate() providers/cloud.firestore/eventTypes/document.update 已更新文件
onWrite() providers/cloud.firestore/eventTypes/document.write 已建立、刪除或更新文件

如果您希望使用者在安裝時設定文件路徑 您的擴充功能,請在 extension.yaml 檔案中加入新參數,並參照 函式中 resource 宣告中的參數:

resources:
  - name: yourFunctionName
    type: firebaseextensions.v1beta.function
    properties:
      eventTrigger:
        eventType: providers/cloud.firestore/eventTypes/document.write
        resource: projects/${PROJECT_ID}/databases/(default)/documents/${YOUR_DOCUMENT_PATH}
  - name: anotherFunction
    type: ...

params:
  - param: YOUR_DOCUMENT_PATH
    label: Cloud Firestore path
    description: Where do you want to watch for changes?
    type: string
    default: path/to/{documentID}  # Specifying a default is optional.
    required: true

Pub/Sub

當訊息發布至特定 主題。

詳情請參閱 Cloud Functions 說明文件中的 Pub/Sub 觸發條件 ,瞭解如何編寫 Pub/Sub 觸發的函式。

函式定義 (僅限第 1 代)

import { pubsub } from "firebase-functions/v1";

export const yourFunctionName = pubsub.topic("topic_name").onPublish((message, context) => {
  // ...
});

資源宣告 (extension.yaml)

resources:
  - name: yourFunctionName
    type: firebaseextensions.v1beta.function
    properties:
      eventTrigger:
        eventType: google.pubsub.topic.publish
        resource: projects/${PROJECT_ID}/topics/topic-name
  - name: anotherFunction
    type: ...

如果您想讓使用者在 他們安裝您的擴充功能,請在您的 extension.yaml 檔案中新增參數 並參照函式 resource 宣告中的參數:

resources:
  - name: yourFunctionName
    type: firebaseextensions.v1beta.function
    properties:
      eventTrigger:
        eventType: google.pubsub.topic.publish
        resource: projects/${PROJECT_ID}/topics/${PUBSUB_TOPIC}
  - name: anotherFunction
    type: ...

params:
  - param: PUBSUB_TOPIC
    label: Pub/Sub topic
    description: Which Pub/Sub topic do you want to watch for messages?
    type: string
    default: topic-name  # Specifying a default is optional.
    required: true

即時資料庫

即時資料庫觸發函式會在路徑符合指定路徑時執行 建立、更新或刪除模式時

請參閱 Cloud Functions 說明文件中的「即時資料庫觸發條件」。 ,瞭解如何編寫 RTDB 觸發的函式。

函式定義 (僅限第 1 代)

import { database } from "firebase-functions/v1";

export const yourFunctionName = database.ref("path/to/{item}")
  .onCreate((snapshot, context) => {
    // ...
  });

export const yourFunctionName2 = database.ref("path/to/{item}")
  .onUpdate((change, context) => {
    // ...
  });

export const yourFunctionName3 = database.ref("path/to/{item}")
  .onDelete((snapshot, context) => {
    // ...
  });

export const yourFunctionName4 = database.ref("path/to/{item}")
  .onWrite((change, context) => {
    // onWrite triggers on creation, update, and deletion.
    // ...
  });

資源宣告 (extension.yaml)

resources:
  - name: yourFunctionName
    type: firebaseextensions.v1beta.function
    properties:
      eventTrigger:
        eventType: providers/google.firebase.database/eventTypes/ref.create
        # DATABASE_INSTANCE (project's default instance) is an auto-populated
        # parameter value. You can also specify an instance.
        resource: projects/_/instances/${DATABASE_INSTANCE}/refs/path/to/{itemId}
  - name: anotherFunction
    type: ...

下表說明如何指定各支援的 Cloud Firestore 事件類型:

Cloud Functions 事件觸發條件 eventType 說明
onCreate() providers/google.firebase.database/eventTypes/ref.create 已建立資料
onDelete() providers/google.firebase.database/eventTypes/ref.delete 已刪除資料
onUpdate() providers/google.firebase.database/eventTypes/ref.update 資料已更新
onWrite() providers/google.firebase.database/eventTypes/ref.write 建立、刪除或更新資料

如果您希望使用者在安裝時設定觀看路徑 您的擴充功能,請在 extension.yaml 檔案中加入新參數,並參照 函式中 resource 宣告中的參數:

resources:
  - name: yourFunctionName
    type: firebaseextensions.v1beta.function
    properties:
      eventTrigger:
        eventType: providers/google.firebase.database/eventTypes/ref.create
        # DATABASE_INSTANCE (project's default instance) is an auto-populated
        # parameter value. You can also specify an instance.
        resource: projects/_/instances/${DATABASE_INSTANCE}/refs/${DB_PATH}
  - name: anotherFunction
    type: ...

params:
  - param: DB_PATH
    label: Realtime Database path
    description: Where do you want to watch for changes?
    type: string
    default: path/to/{itemId}  # Specifying a default is optional.
    required: true

遠端設定

當專案的參數範本 已更新。

詳情請參閱 Cloud Functions 說明文件中的遠端設定觸發條件。 瞭解如何編寫遠端設定觸發函式。

函式定義 (僅限第 1 代)

import { remoteConfig } from "firebase-functions/v1";

export const yourFunctionName = remoteConfig.onUpdate((version, context) => {
  // ...
});

資源宣告 (extension.yaml)

resources:
  - name: yourFunctionName
    type: firebaseextensions.v1beta.function
    properties:
      eventTrigger:
        eventType: google.firebase.remoteconfig.update
        resource: projects/${PROJECT_ID}
  - name: anotherFunction
    type: ...

Cloud Storage

當建立、封存或封存物件時,就會執行 Cloud Storage 觸發函式 或中繼資料有所變更時

請參閱 Cloud Functions 說明文件中的 Cloud Storage 觸發條件: ,瞭解如何編寫 Storage 觸發函式。

函式定義 (僅限第 1 代)

import { storage } from "firebase-functions/v1";

export const yourFunctionName = storage.object().onFinalize((object, context) => {
  // ...
});

export const yourFunctionName2 = storage.object().onMetadataUpdate((object, context) => {
  // ...
});

export const yourFunctionName3 = storage.object().onArchive((object, context) => {
  // ...
});

export const yourFunctionName4 = storage.object().onDelete((object, context) => {
  // ...
});

資源宣告 (extension.yaml)

resources:
  - name: yourFunctionName
    type: firebaseextensions.v1beta.function
    properties:
      eventTrigger:
        eventType: google.storage.object.finalize
        # STORAGE_BUCKET (project's default bucket) is an auto-populated
        # parameter. You can also specify a bucket.
        resource: projects/_/buckets/${STORAGE_BUCKET}
  - name: anotherFunction
    type: ...

下表說明如何指定各支援的 Cloud Storage 事件類型:

Cloud Functions 事件觸發條件 eventType 說明
onFinalize() google.storage.object.finalize 已建立物件
onMetadataUpdate() google.storage.object.metadataUpdate 已更新物件中繼資料
onArchive() google.storage.object.archive 已封存物件
onDelete() google.storage.object.delete 已刪除物件

如果您希望使用者在安裝時設定儲存空間值區 您的擴充功能,請在 extension.yaml 檔案中加入新參數,並參照 函式中 resource 宣告中的參數:

resources:
  - name: yourFunctionName
    type: firebaseextensions.v1beta.function
    properties:
      eventTrigger:
        eventType: google.storage.object.finalize
        resource: projects/_/buckets/${YOUR_BUCKET}
  - name: anotherFunction
    type: ...

params:
  - param: YOUR_BUCKET
    label: Cloud Storage bucket
    description: Which bucket do you want to watch for changes?
    type: selectResource
    resourceType: storage.googleapis.com/Bucket
    default: ${STORAGE_BUCKET}  # Specifying a default is optional.
    required: true

Test Lab

當測試矩陣完成測試時,系統會執行 Test Lab 觸發的函式。

請參閱 Cloud Functions 說明文件中的「Firebase Test Lab 觸發條件」 ,瞭解如何編寫 Test Lab 觸發的函式。

函式定義 (僅限第 1 代)

import { testLab } from "firebase-functions/v1";

export const yourFunctionName = testLab.testMatrix().onComplete((matrix, context) => {
  // ...
});

資源宣告 (extension.yaml)

resources:
  - name: yourFunctionName
    type: firebaseextensions.v1beta.function
    properties:
      eventTrigger:
        eventType: google.testing.testMatrix.complete
        resource: projects/${PROJECT_ID}/testMatrices/{matrixId}
  - name: anotherFunction
    type: ...

Crashlytics 快訊觸發條件

當 Crashlytics 發布 快訊。

請參閱 Cloud Functions 說明文件中的「Firebase 快訊觸發條件」,瞭解 瞭解如何編寫快訊觸發函式。

函式定義 (僅限第 2 代)

import {
  onNewFatalIssuePublished,
  onNewNonfatalIssuePublished,
  onNewAnrIssuePublished,
  onRegressionAlertPublished,
  onVelocityAlertPublished,
  onStabilityDigestPublished,
} from "firebase-functions/v2/alerts/crashlytics";

export const yourFunctionName = onNewFatalIssuePublished((event) => {
  // ...
});

export const yourFunctionName2 = onNewNonfatalIssuePublished((event) => {
  // ...
});

export const yourFunctionName3 = onNewAnrIssuePublished((event) => {
  // ...
});

export const yourFunctionName4 = onRegressionAlertPublished((event) => {
  // ...
});

export const yourFunctionName5 = onVelocityAlertPublished((event) => {
  // ...
});

export const yourFunctionName6 = onStabilityDigestPublished((event) => {
  // ...
});

資源宣告 (extension.yaml)

apis:
  - apiName: eventarc.googleapis.com
    reason: Powers all events and triggers
  - apiName: run.googleapis.com
    reason: Powers 2nd-gen functions

resources:
  - name: yourfunctionname
    type: firebaseextensions.v1beta.v2function
    properties:
      buildConfig:
        runtime: nodejs16
      serviceConfig:
        availableMemory: 512M
      eventTrigger:
        eventType: google.firebase.firebasealerts.alerts.v1.published
        triggerRegion: global
        eventFilters:
          - attribute: alerttype
            value: crashlytics.newFatalIssue
  - name: anotherFunction
    type: ...

您可以使用下列 alerttype

  • crashlytics.newFatalIssue
  • crashlytics.newNonfatalIssue
  • crashlytics.regression
  • crashlytics.stabilityDigest
  • crashlytics.velocity
  • crashlytics.newAnrIssue

Performance Monitoring 快訊觸發條件

當 Performance Monitoring 發布快訊時,就會執行 Performance Monitoring 觸發的函式。

請參閱 Cloud Functions 說明文件中的「Firebase 快訊觸發條件」,瞭解 瞭解如何編寫快訊觸發函式。

函式定義 (僅限第 2 代)

import { onThresholdAlertPublished } from "firebase-functions/v2/alerts/performance";

export const yourFunctionName = onThresholdAlertPublished((event) => {
  // ...
});

資源宣告 (extension.yaml)

apis:
  - apiName: eventarc.googleapis.com
    reason: Powers all events and triggers
  - apiName: run.googleapis.com
    reason: Powers 2nd-gen functions

resources:
  - name: yourfunctionname
    type: firebaseextensions.v1beta.v2function
    properties:
      buildConfig:
        runtime: nodejs16
      serviceConfig:
        availableMemory: 512M
      eventTrigger:
        eventType: google.firebase.firebasealerts.alerts.v1.published
        triggerRegion: global
        eventFilters:
          - attribute: alerttype
            value: performance.threshold
  - name: anotherFunction
    type: ...

應用程式發布快訊觸發條件

當應用程式發行發布快訊時,就會執行應用程式發布觸發函式。

請參閱 Cloud Functions 說明文件中的「Firebase 快訊觸發條件」,瞭解 瞭解如何編寫快訊觸發函式。

函式定義 (僅限第 2 代)

import {
  onNewTesterIosDevicePublished,
  onInAppFeedbackPublished
} from "firebase-functions/v2/alerts/appDistribution";

export const yourFunctionName = onNewTesterIosDevicePublished((event) => {
  // ...
});

export const yourFunctionName2 = onInAppFeedbackPublished((event) => {
  // ...
});

資源宣告 (extension.yaml)

apis:
  - apiName: eventarc.googleapis.com
    reason: Powers all events and triggers
  - apiName: run.googleapis.com
    reason: Powers 2nd-gen functions

resources:
  - name: yourfunctionname
    type: firebaseextensions.v1beta.v2function
    properties:
      buildConfig:
        runtime: nodejs16
      serviceConfig:
        availableMemory: 512M
      eventTrigger:
        eventType: google.firebase.firebasealerts.alerts.v1.published
        triggerRegion: global
        eventFilters:
          - attribute: alerttype
            value: appDistribution.inAppFeedback
  - name: anotherFunction
    type: ...

您可以使用下列 alerttype

  • appDistribution.newTesterIosDevice
  • appDistribution.inAppFeedback

自訂事件觸發條件 (Eventarc)

當特定事件類型發布至 特定頻道。

請參閱 Cloud Functions 中的「建立及處理自訂事件觸發條件」。 參閱說明文件,瞭解如何編寫 Eventarc 觸發函式。

您也可以發布擴充功能中的事件,讓使用者能插入擴充功能 自訂邏輯請參閱「在 擴充功能

函式定義 (僅限第 2 代)

import { onCustomEventPublished } from "firebase-functions/v2/eventarc";

export const yourFunctionName = onCustomEventPublished((event) => {
  // ...
});

資源宣告 (extension.yaml)

apis:
  - apiName: eventarc.googleapis.com
    reason: Powers all events and triggers
  - apiName: run.googleapis.com
    reason: Powers 2nd-gen functions

resources:
  - name: yourfunctionname
    type: firebaseextensions.v1beta.v2function
    properties:
      # LOCATION is a user-configured parameter value specified by the user
      # during installation.
      location: ${param:LOCATION}
      buildConfig:
        runtime: nodejs16
      serviceConfig:
        availableMemory: 512M
        timeoutSeconds: 60
      eventTrigger:
        eventType: firebase.extensions.storage-resize-images.v1.complete
        channel: projects/${param:PROJECT_ID}/locations/us-central1/channels/firebase
  - name: anotherFunction
    type: ...

安裝擴充功能時,頻道必須已存在。舉例來說 您可以仰賴建立管道的其他擴充功能自訂事件 請指示使用者先安裝該擴充功能。

上述範例會為「預設」建立自訂事件觸發條件Firebase 頻道 (us-central1 個區域)。你可以設定頻道名稱和區域 還可以透過參數自訂及自訂例如:


params:
  - param: EVENTARC_CHANNEL_NAME
    label: Eventarc channel name
    description: What is the name of the Eventarc channel.
    default: firebase
    type: string
    required: true

resources:
  - name: yourfunctionname
    type: firebaseextensions.v1beta.v2function
    properties:
      location: ${param:LOCATION}
      eventTrigger:
        eventType: firebase.extensions.storage-resize-images.v1.complete
        channel: projects/${param:PROJECT_ID}/locations/${param:LOCATION}/channels/${param:EVENTARC_CHANNEL_NAME}