简体   繁体   English

Azure App Service(Windows)配置变量

[英]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.

相关问题 nestjs 到 azure windows 应用服务 - web.config 设置 - nestjs to azure windows app service - web.config settings 在 Azure 应用服务中为 NodeJ 使用多核应用服务计划 (Windows) - Leveraging MultiCore App Service Plan (Windows) for NodeJs in Azure App Service 木偶无头Chrome是否可以在Azure App Service的Windows容器中工作? - Does puppeteer headless chrome work in a Windows container in Azure App Service? Windows Azure虚拟机和云服务Node.js应用程序部署 - Windows Azure Virtual Machine and cloud service nodejs app deploy 天蓝色应用服务上的角度应用 - 从资源文件夹加载配置文件时出现404错误 - Angular app on azure app service - 404 errors when loading config file from assets folder 在 Azure 应用服务 (Linux) 上运行的 Node/Next/React 应用是否需要 web.config 文件? - Is the web.config file required for a Node/Next/React App running on Azure App Service (Linux)? 使用node-windows将应用程序设置为Windows Service时,node-config不读取配置文件 - node-config doesn't read config files when app is set up as Windows Service using node-windows 在app.config中注入服务? - Inject service in app.config? Windows azure移动服务脚本 - Windows azure mobile service script 在基于 Windows 的 Azure 应用服务上部署服务器端 NodeJS 应用(CI/CD 使用 Azure DevOps) - Deploying server-side NodeJS app on Windows-based Azure App Service (CI/CD Using Azure DevOps)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM