5

When creating an App Service in Azure and selecting Docker Container as a type of App, where do you set Environment Variables?

My App is built in Azure by: 1. Create Resource > App Service > Publish > Choose Docker Image (rather than code) 2. Point to Docker container in Azure registry.

The app builds fine, but I wish to pass in environment variables during the docker run command (on other services you simply set environment variables). When the app builds, you can see in the logs the app service runs" docker run...." and passes in --env variables. Like so

"docker run -d -p 56996:80 --name nameofapp_7 -e WEBSITE_SITE_NAME=AngularApp"

What I need to know is where in the Azure Portal can you set the variables to be passed into the run command. i.e. WEBSITE_SITE_NAME ?

user537352
  • 51
  • 1
  • 2

1 Answers1

3

Any app settings you configure in the web application are passed into the container as environment variables. You can configure these in the portal, through CLI or ARM Template.

Sam Cogan
  • 38,158
  • 6
  • 77
  • 113
  • 1
    This doesn't work for me. In my docker file I have: ``` ENV Storage:PersistentVolume= ``` In my app service, under configuration --> Application settings, I have entered "Storage:PersistentVolume" and specified a value. When the application runs, it shows me the environment variable value - it's unset. Is there some special requirement I am missing here? – Darrell Apr 28 '20 at 16:19
  • Found the cause of my issue. From the Log Stream I was seeing a line stating that Confiuguration of the container was failing. My environmnet variable was called Foo:Bar and it seems the colon was the cause of the error. When I changed the environment variable name to Foo__Bar (replacing the colon with double underscore as mentioned here: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-3.1#default) it worked. – Darrell Apr 28 '20 at 16:50