Container Apps - Referencing env vars through other environment variables
This post will quickly go over how to add environment variables to Azure Container Apps that reference other environment variables
Overview
With Azure Container Apps, you can add environment variables that reference other environment variables you’ve created - you can also reference “pre-existing” environment variables (these are generally the Kubernetes-based ones injected into containers within a pod).
The syntax to do this is: $(MY_REFERENCED_ENV_VAR)
Casing doesn’t matter, by the syntax of $()
is what ultimately makes this work. Below is an example:
We have the environment variables with their key/value pairs of:
ENV_VAR_A
:firstvalue
ENV_VAR_B
:secondvalue
ENV_VAR_CONCAT
:$(ENV_VAR_A)
If we go into Console and run something like env
, we can see this value expands appropriately:
You can do this with “pre-existing” environment variables too. This example uses CONTAINER_APP_REVISION
as the value, which can we can see gets expanded: