Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Web App for Containers not setting Environment Variables

I have a docker image being deployed from Azure Container Registry. 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. It is a Node app accessing environment variables with process.env.VariableName.

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"

I have tried the following.

  • Setting Applications Settings in the Azure Portal. 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.

  • I have tried using a Docker compose file that sets the environment variables but again process.env.VariableName is empty.

  • I have even updated the VSTS build arguments passing the Variable to my Docker file on build which in turn sets the environment variable. Again no variable passed to the running Docker image.

My conclusion is that custom environment variables are not allowed in Azure Web App for Containers?

Am I doing something wrong?

like image 571
Lee Dale Avatar asked Sep 19 '18 07:09

Lee Dale


People also ask

How do you list environment variables in a container?

Fetch Using docker exec Command Here, we are executing the /usr/bin/env utility inside the Docker container. Using this utility, you can view all the environment variables set inside Docker containers.


1 Answers

As per the documentation the app settings are injected into the process as environment variables, however the environment variable name is prefixed with APPSETTING_, so in your Node application you would need to access the app setting with process.env.APPSETTING_VariableName.

like image 117
Marky Avatar answered Sep 24 '22 21:09

Marky