Why you don't see ENV variables in Azure Function settings When you define environment variables inside a Dockerfile, they exist only within the container at runtime and do not appear in the Azure Function App Settings. Azure Functions (when running in a container) do not automatically extract environment variables from the container itself into the Function App settings. To properly manage configuration, it's recommended to set environment variables at the Azure Function App level rather than embedding them inside the Dockerfile.
Where to store application configuration (including secrets) For a containerized Azure Function, consider the following best practices:
- Azure Function App settings (best for non-sensitive configuration)
- Go to Azure Portal → Your Function App → Configuration → Application settings.
- Add environment variables manually here.
- These values override any variables defined in the Dockerfile.
- Azure Key Vault (best for secrets & sensitive data)
- Store secrets (like API keys, connection strings) in Azure Key Vault.
- Reference Key Vault secrets in Function App Settings using a Managed Identity.
- This ensures secrets are securely retrieved at runtime without being stored in the container.
- Azure App configuration (best for dynamic configuration management)
- Azure App Configuration allows externalized configuration management for cloud-native applications.
- It supports feature flags, dynamic settings updates, and Key Vault integration.
How to Update Configuration Without Releasing a New Image Since embedding environment variables in the Docker image is not ideal for updates, you should externalize configuration to the Azure Function App settings.
Manual update for testing
- In Azure Portal:
- Go to Function App → Configuration → Application settings.
- Add or update an environment variable.
- Click Save → This will restart the function and apply the changes.
- Via Azure CLI:
az functionapp config appsettings set --name <FunctionAppName> --resource-group <ResourceGroupName> --settings "MY_SETTING=value"
How to automate configuration updates using Infrastructure as Code (IaC) If you want to manage configuration updates as code, use Terraform, Bicep, or ARM templates.
Example: Terraform
resource "azurerm_function_app" "example" {
name = "example-function-app"
resource_group_name = "example-rg"
location = "East US"
app_settings = {
"APP_ENV" = "staging"
"DATABASE_URL" = "https://my-db-url"
"STORAGE_ACCOUNT" = "mystorageaccount"
}
}
To update the configuration:
terraform apply -auto-approve
This redeploys the configuration without requiring a new image build.
Example: Bicep
resource functionApp 'Microsoft.Web/sites@2021-02-01' = {
name: 'myFunctionApp'
location: resourceGroup().location
properties: {
siteConfig: {
appSettings: [
{ name: 'APP_ENV', value: 'staging' }
{ name: 'DATABASE_URL', value: 'https://my-db-url' }
]
}
}
}
Use az deployment group create
to deploy the changes.
To summarize
- Store secrets in Azure Key Vault and reference them in Function App settings.
- Keep non-sensitive configs in Function App settings for easy updates.
- Use Azure App Configuration for dynamic settings.
- Manage updates via IaC (Terraform/Bicep) to ensure consistency.
- Avoid storing configs inside the Dockerfile to keep images immutable.
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.
hth
Marcin