7
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

FirebaseのFunctionsのconfigを取得、設定する方法

Last updated at Posted at 2020-09-10

取得・確認

Firebase SDKを使っていて、Firebase Cloud Functionsのconfigの
環境変数に何が設定されているか確認したい場合に使います。

どの環境に向いているか確認

例ではproduction-projectに向いています。
この時点でfirebase系のエラーが出た人はfirebase-toolsが入っているか、ログインされているかを確認してください。

$ firebase use
Active Project: production (production-project)

Project aliases for /Users/MyUserName/projects/firebaseProject:

  development (development-project)
  staging (staging-project)
* production (production-project)

現在の環境構成を取得する

詳細は下記のURLの通リです。
https://firebase.google.com/docs/functions/config-env?hl=ja#retrieve_current_environment_configuration

何も設定されていない場合は{}だけが表示されます。

$ firebase functions:config:get
{
  "fb": {
    "token": "this-is-token_hogehoge7hoge14hogehoge7hoge14hogehoge7hoge14hogehoge7hoge14hogehoge7hoge14hogehoge7hoge14hogehoge7hoge14hogehoge7hoge14"
  }
}

設定・登録(例: tokenの登録)

firebase useで向き先を確認してください。
もしも想定している向き先でない場合はfirebase use developの様に向き先を指定して変更してください。

tokenの生成

$ firebase login:ci

Visit this URL on this device to log in:
{ここにURLが表示される}

Waiting for authentication...

✔  Success! Use this token to login on a CI server:

{ここにTokenが表示されるのでコピーしておく}

Example: firebase deploy --token "$FIREBASE_TOKEN"

環境構成の設定(config)

$firebase functions:config:set fb.token={コピーしておいたtoken}

✔  Functions config updated.

Please deploy your functions for the change to take effect by running firebase deploy --only functions

設定した状態の確認

$ firebase functions:config:get
{
  "fb": {
    "token": "{登録したtokenが表示される}"
  }
}
7
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?