0
votes

I have a release pipeline in Azure DevOps. This is pulling a docker image from an ACR and publishing to a Web App (linux container). All works fine (container is published & runs as expected), however I can't seem to pass in any custom environment variables at runtime to the container.

Release pipeline

In the pipeline 'Deploy Azure App Service' under the variable tab, I have added, MY_ENV test01 and then under 'App settings' I have added

-e MY_ENV

The release is published and the image is updated ok.

Container Logs

The docker run command in the logs does not have the environment variable I was expected -e MY_ENV in the command, but it missing.

Anyone know how to pass an ENV variable to a docker container at runtime via an Azure DevOps release pipeline?

Thanks

1

1 Answers

1
votes

Looks like the way you are passing the App settings is wrong in your deploy app service pipeline task -e MY_ENV. Instead just directly add -MY_ENV test01 as part of your app settings. and it should be available as part of your environment. see : https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-rm-web-app-deployment?view=azure-devops

enter image description here

If this still fails, you can pass/set your environment variables as follows : https://docs.microsoft.com/en-us/azure/app-service/configure-custom-container?pivots=container-linux#configure-environment-variables

You can run this Azure CLI command as part of your devops pipeline (https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-cli?view=azure-devops)