[英]Azure App Service (Windows) Config Variable
I'm having an issue reading env variables on Azure App Service Windows instance. 我在读取Azure App Service Windows实例上的环境变量时遇到问题。 I use dotenv nodejs package for storing my env variables in .env file.
我使用dotenv nodejs包将我的env变量存储在.env文件中。 It works perfectly fine on my local machine (Windows 10), but the same does not when hosted on a Windows App service.
它在我的本地计算机(Windows 10)上运行良好,但在Windows App服务上托管时却没有。 I tried some troubleshooting by printing out the env variables at run time and I get blank output for the same.
我通过在运行时打印出env变量来尝试一些故障排除,并且得到了相同的空白输出。 Somehow it's not able to read the variables in the .env file.
不知何故,它无法读取.env文件中的变量。
I also made sure that the .env file and the entries are intact on the deployed host by logging onto the console. 我还通过登录控制台来确保.env文件和条目在已部署主机上完好无损。
App Service injects process.env.PORT into your application, so the code uses the variable to know which port to listen. App Service将process.env.PORT注入到您的应用程序中,因此代码使用该变量来知道要监听的端口。 Open index.js and find the following line: const port = process.env.PORT ||
打开index.js并找到以下行:const port = process.env.PORT || 1337;
1337;
If you haven't done this already, In App Service, you can set app settings outside of your app code. 如果尚未执行此操作,则可以在App Service中在应用程序代码之外设置应用程序设置。 Then you can access them using the standard Node.js pattern.
然后,您可以使用标准的Node.js模式访问它们。 For example, to access an app setting called NODE_ENV, use the following code: process.env.NODE_ENV
例如,要访问名为NODE_ENV的应用程序设置,请使用以下代码:process.env.NODE_ENV
To fetch more details, Navigate to the Debug Console site https://yoursite.scm.azurewebsites.net/DebugConsole Go into your site/wwwroot directory 要获取更多详细信息,请导航到调试控制台站点https://yoursite.scm.azurewebsites.net/DebugConsole进入您的site / wwwroot目录
recycleSignalEnabled - The default value is false. recycleSignalEnabled-默认值为false。 If enabled, your node application can connect to a named pipe (environment variable IISNODE_CONTROL_PIPE) and send a “recycle” message.
如果启用,则您的节点应用程序可以连接到命名管道(环境变量IISNODE_CONTROL_PIPE)并发送“回收”消息。 This causes the w3wp to recycle gracefully.
这将导致w3wp正常回收。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.