Manage environment variables on Azure Container Apps

In Azure Container Apps, you're able to set runtime environment variables. These variables can be set as manually entries or as references to secrets. These environment variables are loaded onto your Container App during runtime.

Configure environment variables

You can configure the Environment Variables upon the creation of the Container App or later by creating a new revision.

Note

To avoid confusion, it is not recommended to duplicate environment variables. When multiple environment variables have the same name, the last one in the list takes effect.

If you're creating a new Container App through the Azure portal, you can set up the environment variables on the Container section:

Screenshot of Container App creation page.

Add environment variables on existing container apps

After the Container App is created, the only way to update the Container App environment variables is by creating a new revision with the needed changes.

  1. In the Azure portal, search for Container Apps and then select your app.

    Screenshot of the Azure portal search bar with Container App as one of the results.

  2. In the app's left menu, select Revisions and replicas > Create new revision

    Screenshot of Container App Revision creation page.

  3. Then you have to edit the current existing container image:

    Screenshot of Container App Revision container image settings page.

  4. In the Environment variables section, you can Add new Environment variables by clicking on Add.

  5. Then set the Name of your Environment variable and the Source (it can be a reference to a secret).

    Screenshot of Container App Revision container image environment settings section.

    1. If you select the Source as manual, you can manually input the Environment variable value.

      Screenshot of Container App Revision container image environment settings section with one of the environments source selected as Manual.

Built-in environment variables

Azure Container Apps automatically adds environment variables that your apps and jobs can use to obtain platform metadata at run-time.

Apps

The following variables are available to container apps:

Variable name Description Example value
CONTAINER_APP_NAME The name of the container app. my-containerapp
CONTAINER_APP_REVISION The name of the container app revision. my-containerapp--20mh1s9
CONTAINER_APP_HOSTNAME The revision-specific hostname of the container app. my-containerapp--20mh1s9.<DEFAULT_HOSTNAME>.<REGION>.azurecontainerapps.io
CONTAINER_APP_ENV_DNS_SUFFIX The DNS suffix for the Container Apps environment. To obtain the fully qualified domain name (FQDN) of the app, append the app name to the DNS suffix in the format $CONTAINER_APP_NAME.$CONTAINER_APP_ENV_DNS_SUFFIX. <DEFAULT_HOSTNAME>.<REGION>.azurecontainerapps.io
CONTAINER_APP_PORT The target port of the container app. 8080
CONTAINER_APP_REPLICA_NAME The name of the container app replica. my-containerapp--20mh1s9-86c8c4b497-zx9bq

Jobs

The following variables are available to Container Apps jobs:

Variable name Description Example value
CONTAINER_APP_JOB_NAME The name of the job. my-job
CONTAINER_APP_JOB_EXECUTION_NAME The name of the job execution. my-job-iwpi4il

Next steps