简体   繁体   English

用于容器的 Azure Web 应用程序未设置环境变量

[英]Azure Web App for Containers not setting Environment Variables

I have a docker image being deployed from Azure Container Registry.我有一个从 Azure 容器注册表部署的 docker 映像。 Everything works fine except that I expect to be able to see environment variables being passed to my running docker image from the Application Settings configured in the portal.一切正常,除了我希望能够看到环境变量从门户中配置的应用程序设置传递给我正在运行的 docker 映像。 It is a Node app accessing environment variables with process.env.VariableName.它是一个使用 process.env.VariableName 访问环境变量的 Node 应用程序。

As an example its says here https://blogs.msdn.microsoft.com/waws/2017/09/08/things-you-should-know-web-apps-and-linux/#SetEnvVar … "App Settings are injected into your app as environment variables at runtime"作为一个例子,它在这里说https://blogs.msdn.microsoft.com/waws/2017/09/08/things-you-should-know-web-apps-and-linux/#SetEnvVar ...“应用程序设置被注入在运行时作为环境变量进入您的应用程序”

I have tried the following.我尝试了以下方法。

  • Setting Applications Settings in the Azure Portal.在 Azure 门户中设置应用程序设置。 These are supposed to get passed to the running Docker image as per the documentation but process.env.VariableName in my Node application is not set.这些应该按照文档传递给正在运行的 Docker 映像,但我的 Node 应用程序中的 process.env.VariableName 未设置。

  • I have tried using a Docker compose file that sets the environment variables but again process.env.VariableName is empty.我曾尝试使用设置环境变量的 Docker 撰写文件,但 process.env.VariableName 再次为空。

  • I have even updated the VSTS build arguments passing the Variable to my Docker file on build which in turn sets the environment variable.我什至更新了 VSTS 构建参数,在构建时将变量传递给我的 Docker 文件,从而设置环境变量。 Again no variable passed to the running Docker image.同样没有变量传递给正在运行的 Docker 镜像。

My conclusion is that custom environment variables are not allowed in Azure Web App for Containers?我的结论是 Azure Web App for Containers 中不允许自定义环境变量?

Am I doing something wrong?难道我做错了什么?

根据文档,应用程序设置作为环境变量注入到进程中,但是环境变量名称以APPSETTING_为前缀,因此在您的 Node 应用程序中,您需要使用process.env.APPSETTING_VariableName访问应用程序设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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