admin 管理员组文章数量: 1086019
I have successfully run a Node.js Webapp on Azure, which is connecting to an Azure SQL DB. Everything is working fine when entering the DB details manually into the code.
The issue es when I try and use the connection details as environment variables.
My Node.js connection looks like this:
const config = {
user: `${APPSETTING_user}`,
password: `${APPSETTING_pw}`,
server: `${APPSETTING_host}`,
database: `${APPSETTING_db}`,
options:
{
encrypt: true
}
};
In the Azure Webapp, I have done the following:
- Application Settings > App Settings
Entered the following:
- Key: user, Value: {db user login}
- Key: pw, Value: {my password}
- Key: host, Value: {SQL server address}
- Key: db, Value: {db name>}
Correct working values in plain text without curly brackets obviously.
I am getting an error on load that is cannot find db server: ${APPSETTING_host}
I have been looking through documentation and tutorials, which is limited or out of date on this - however from what I have read apparently I am doing it correctly?
I have successfully run a Node.js Webapp on Azure, which is connecting to an Azure SQL DB. Everything is working fine when entering the DB details manually into the code.
The issue es when I try and use the connection details as environment variables.
My Node.js connection looks like this:
const config = {
user: `${APPSETTING_user}`,
password: `${APPSETTING_pw}`,
server: `${APPSETTING_host}`,
database: `${APPSETTING_db}`,
options:
{
encrypt: true
}
};
In the Azure Webapp, I have done the following:
- Application Settings > App Settings
Entered the following:
- Key: user, Value: {db user login}
- Key: pw, Value: {my password}
- Key: host, Value: {SQL server address}
- Key: db, Value: {db name>}
Correct working values in plain text without curly brackets obviously.
I am getting an error on load that is cannot find db server: ${APPSETTING_host}
I have been looking through documentation and tutorials, which is limited or out of date on this - however from what I have read apparently I am doing it correctly?
Share Improve this question asked Oct 30, 2017 at 15:52 Jim DoverJim Dover 6233 gold badges18 silver badges32 bronze badges1 Answer
Reset to default 5You need to use process.env.ENV_VARIABLE
to read environment variables in Node. So in your case, it would be process.env.user
, process.env.pw
, etc...
See Read environment variables in Node.js for details.
本文标签: javascriptEnvironment variables in Azure WebApp with NodejsStack Overflow
版权声明:本文标题:javascript - Environment variables in Azure WebApp with Node.js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1744062383a2526959.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论