Azure App Service Docker containers and variables…

I was involved in setting up some Docker containers in Azure App Service at work and noticed that the environment variables set in the compose file weren’t being visible to the container. This was a container image given by a 3rd party developer and they put it down as a bug in Azure App Service. I couldn’t find much about it online so figured they were probably right; and moreover I could work around the issue by setting the variables in the “Configuration” block of the App Service – not as convenient as having them all in a compose file, but does the job.

Later I decided to dig a bit more into this and created two containers “rakheshster/nginxvars” (GitHub) and “rakheshster/phpvars” (GitHub). Since there was no way for me to SSH into the App Service to explore variables, I wanted some way of outputting these variables to a web page so I could just visit it publicly via the browser. I made two containers as I was initially curious if variables were blocked or not and using the Nginx web server container was the easiest way. Later I realized the developers were using PHP and so wanted to double check this wasn’t blocked in PHP either.

For Nginx I make use a script that outputs all the variables to a public location and then starts Nginx:

If I visit http://myappsvcwebsite/more/env.txt I get a text file with all the env variables. And sure enough I can see whatever variables I pass in via Docker Compose – Azure does not block them. I also wanted to check if I had multiple containers within the same App Service do the other containers behave any differently? They do not. (Since I can’t access the other containers directly I simply share the storage amongst all these and have each container output to the same file – thus I can see the variables of all the containers).

The PHP variant was even simpler. I simply pull the official PHP container but add an env.php file with the following contents to display all the variables:

That too worked. Weird then that developers said their containers weren’t able to see the variables.