Environment variables

How to set up the function execution environment.

The environment variables of the functions are managed with dotenv.

In order to make your function environment variables available through process.env, create a .env file inside the emulator folder and add variables on new lines in the form of NAME=VALUE. For example:

Assuming we have a function containing the following function.config.json:

{
    "name": "helloWorld",
       "description": "Http function that responds with Hello World!",
    "tags": [ "demo", "first-function"],
       "trigger": {
        "provider": "https",
        "event": "request"
    },
    "env": [{
        "name": "SOME_VAR",
        "description": "Check the implementation in main.js to see how we use the environment variable while coding."
    }, {
        "name": "ANOTHER_VAR",
        "description": "Check the implementation in main.js to see how we use the environment variable while coding."
    }]
}

The content of your .env file must be:

SOME_VAR=Some value
ANOTHER_VAR=Some value for another var

Last updated