5

Why can't I use env variables as I would with Google Cloud Functions? As I understand, Firebase functions sit on top of Google Cloud. With Firebase functions you can use environment configuration but is not the same.

I have done both implementations but I find it easier to work with environment variables with google cloud functions.

Maybe I just don't know how to do it and I can't find any documentation, so if someone can point me in the right direction I will appreciate it. If there are any advantages of doing it the firebase functions way let me know.

Google cloud functions env docs

Firebase functions config env docs

user835611
  • 2,309
  • 2
  • 21
  • 29
ajorquera
  • 1,297
  • 22
  • 29

2 Answers2

0

The Firebase CLI manages the process environment variables for deployed functions. It does not offer a way to change or override that management, other than modifying its source code to do what you want.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • 1
    Is it possible to use gcloud cli to deploy firebase functions? – ajorquera Mar 06 '20 at 21:19
  • I won't say that it's *impossible*, but I think you'll have a very hard time making this happen - it's not a supported option. – Doug Stevenson Mar 06 '20 at 21:20
  • Any particular reason why they would need to work differently. Is just that the firebase approach seems odd to me – ajorquera Mar 06 '20 at 21:22
  • 1
    It was a decision that the Firebase team made. If you want to send feedback to the Firebase team, please go through Firebase support. https://support.google.com/firebase/contact/support – Doug Stevenson Mar 06 '20 at 21:23
-1

To store environment data for Firebase functions, you can use the firebase functions:config:set command in the Firebase CLI. Each key can be namespaced using periods to group related configuration together. Keep in mind that only lowercase characters are accepted in keys; uppercase characters are not allowed.

For instance, to store the Client ID and API key for "Some Service", you might run:

firebase functions:config:set someservice.key="THE API KEY" someservice.id="THE CLIENT ID"

To inspect what's currently stored in environment config for your project, you can use firebase functions:config:get. It will output JSON something like this:

{
  "someservice": {
    "key":"THE API KEY",
    "id":"THE CLIENT ID"
  }
}
user835611
  • 2,309
  • 2
  • 21
  • 29