简体   繁体   中英

Environment variables in nodejs deployed app

I am developing a Node application in which I am connecting to an azure database. I would like to keep the credentials as environment variables. I have a .env file and I have the credentials in that. When I run the app locally I can fetch the credentials from the file but when it is deployed in Azure, the process.env.SERVER is returning undefined and so I am unable to connect to the server.

In Azure Web Apps, we can define these environment variables in section Application settings -> App settings by using Azure portal :

在此处输入图片说明

Then these variables can be accessed from our Node.js code via process.env["variablename"] .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM