0
votes

I have a docker image that requires an ENV variable to start in the correct mode (eg. $ docker run -e "env_var_name=another_value" ...). The Dockerfile starts with:

FROM nginx:alpine
ENV env_var_name standalone

In the Azure Devops release pipeline I use AzureRmWebAppDeployment@3 to create the docker container but I do not understand where I can do the ENV settings. I cannot use the .env file. many thanks

1
I found the solution that I think is the correct approach and not a workaround: this kind of settings are not part of the release pipeline but are part of the Application Service hosted by Azure, for this reason it is correct that the pipeline has no options for that while the Application Service > Settings has. So I just added the ENV variables here where other DOCKER variables are configured by Azure itself.mixer

1 Answers

0
votes

You can add it as AppSettings to the Application Service by setting up AzureRmWebAppDeployment task in the pipeline, here is a template YAML sample:

 #11. Deploy web app
    - task: AzureRMWebAppDeployment@4
      displayName: Deploy web app on Linux container
      inputs:
        appType: webAppContainer
        DockerImageTag: ${{ parameters.image_tag }}
        DockerNamespace: ${{ parameters.registry_url }}
        DockerRepository: ${{ parameters.repository_name }}
        ...
        AppSettings: ${{ parameters.webapp_settings }}

example of webapp_settings values: webapp_settings: '-key1 "text" -key2 12 -otherKey 34'

App Settings are injected into your app as environment variables at runtime. (see here)