Access to azure app setting environment variables from nodejs

Viewed 173

I set environment variables in the azure app service through the settings enter image description here

and I want to change to the environment variable I created through the code How can it be accessed? something like this

app.listen(PORT, () => {
      console.log(`Example app listening at http://localhost:${config.PORT}`)
    });

but it not recognizes the variable PORT

1 Answers

Similarly how you access environment variables in your local environment, You need to use process.env.ENV_VARIABLE to read environment variables in Node.

var port = process.env.PORT;
Related