WebApp for Containers - App Settings not passed through to container as Environment Variables

rchambers 31 Reputation points
2020-11-30T02:44:27.627+00:00

I've created an Web App for Containers instance using a custom container; however, it looks as though my Web App's "App Settings" are not being correctly passed into the container as environment variables. When viewing the deployment logs, I can see other environment variables being passed through at runtime, ie: WEBSITES_ENABLE_APP_SERVICE_STORAGE, but my custom settings don't seem to work.

docker run -d -p 1906:80 --name test-deploy_1_a5aeafaa -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=true -e WEBSITE_SITE_NAME=test-deploy -e WEBSITE_AUTH_ENABLED=False -e PORT=80 -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=test-deploy.azurewebsites.net -e WEBSITE_INSTANCE_ID=<id>test.azurecr.io/app:latest    

If I SSH into the container directly and try to use either env or printenv, I don't see any of the app settings I configured listed. I'm also able to confirm that the application's code is not able to retrieve the specific environment variables due to the log messages available through the application itself.

I'm following the same approach to defining app settings for custom containers as is described here: https://video2.skills-academy.com/en-us/azure/app-service/configure-custom-container?pivots=container-linux#configure-environment-variables

Has anyone run into this issue before, and can offer any advice?

Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
670 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,289 questions
0 comments No comments
{count} vote

Accepted answer
  1. Ryan Hill 26,866 Reputation points Microsoft Employee
    2020-11-30T15:02:39.643+00:00

    Hi @mrtheplague,

    Since you're using a customer container, try adding the following line to your container init script of your Linux based image. You will notice this line in other oryx based images.

    eval $(printenv | sed -n "s/^\([^=]\+\)=\(.*\)$/export \1=\2/p" | sed 's/"/\\\"/g' | sed '/=/s//="/' | sed 's/$/"/' >> /etc/profile)  
    

    If, however, your container is Windows based, environment variables are injected into System.ConfigurationManager, in which case you won't be able to see them via SSH but should see them via the .NET API.

    Regards,
    Ryan


0 additional answers

Sort by: Most helpful