This demo shows how to mount configuration files as secrets in Azure Container Apps using volume mounts.
This allows for configuration files to be loaded into the container from the host machine (like a ConfigMap)
The example:
- Creates an Azure Container App running nginx:alpine
- Injects an nginx configuration file from this repo nginx.conf
The nginx configuration is loaded from nginx.conf
and stored as a secret named nginx-config-content
:
secrets = [
{
name = "nginx-config-content"
value = file("${path.module}/nginx.conf")
}
]
This "secret" is mounted as a volume in the container:
volumeMounts = [
{
volumeName = "nginx-config"
mountPath = "/etc/nginx/conf.d"
}
]
volumes = [
{
name = "nginx-config"
storageType = "Secret"
secrets = [
{
secretRef = "nginx-config-content"
path = "default.conf"
}
]
}
]
- Deploy the infrastructure:
terraform init
terraform plan
terraform apply
- Access the application using the output URL to verify the nginx configuration is loaded correctly.