はじめに
Cloud FunctionsをそのままFirebase CLIからデプロイすると、デフォルトのリージョンus-central1
に設定されてしまいます。
また、デプロイしてしまうとリージョンが変更できないので、デプロイする前に設定しなければなりません。
書き方
Cloud Functionsの第2世代が公開されてますが、第1世代と第2世代では設定方法が変更されています。
以下、typescriptで作成しています。
第1世代
import * as functions from 'firebase-functions'
export const testFunction = functions
.region('asia-northeast1')
.https
.onCall((req) => {
// onCallの処理
})
第2世代
import * as functions from 'firebase-functions/v2'
export const testfunction = functions
.https
.onCall({region: 'asia-northeast1'}() => {
// onCallの処理
})
- 関数名が第2世代では大文字が使えず、小文字だけになった。
- リージョンを指定する場所
が変更されています。(これはonRequest
も同様です)
結果
公式ドキュメントにも設定方法が載っています。
参考
https://zenn.dev/nananaoto/articles/3efc945c845910