ajorquera
ajorquera

Reputation: 1309

Why can't I use ENV variables with Firebase functions

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

Upvotes: 5

Views: 4762

Answers (2)

user835611
user835611

Reputation: 2376

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"
  }
}

Upvotes: -1

Doug Stevenson
Doug Stevenson

Reputation: 317808

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.

Upvotes: 0

Related Questions