Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
App-level secrets are configuration values that your function code and bindings consume at runtime. Unlike Functions access keys, which secure HTTP endpoints, app-level secrets are the credentials your application needs to connect to other services.
Common examples include:
- Infrastructure connections -
AzureWebJobsStorageconnection strings, trigger and binding connections for Event Hubs, Service Bus, Cosmos DB, and SQL. - Business credentials - third-party API keys, database passwords, SaaS platform tokens.
- Custom configuration - any sensitive value your code reads from environment variables.
Choose a storage option
Azure Container Apps gives you two ways to store app-level secrets:
| Option | Best for | Centralized management | Automatic rotation | Audit logging |
|---|---|---|---|---|
| Container Apps secrets | Dev/test, simple single-app workloads | No - scoped to one app | No | Activity logs only |
| Key Vault references | Production, multi-app, compliance | Yes - across all apps | Yes (versionless URI) | Full Key Vault diagnostics |
Tip
Start with Container Apps secrets for simplicity. Move to Key Vault references when you need centralized management, automatic rotation, or compliance-grade auditing.
Prerequisites
- An Azure account with an active subscription. Create an account for free.
- Azure CLI version 2.40.0 or higher.
- An existing Azure Functions app in Container Apps or permissions to create one.
Use Container Apps secrets
Container Apps stores secrets in the app's configuration.secrets array and encrypts values at rest. You can reference secrets in environment variables, scale rules, volume mounts, and Dapr components.
Store a secret
Go to your Functions container app in the Azure portal.
Under Settings, select Secrets.
Select Add and enter the following values:
Property Value Name A secret name such as database-password. Use lowercase letters, numbers, and hyphens only.Type Container Apps Secret Value Your secret value. Select Add.
Reference the secret in an environment variable
After you store a secret, reference it in an environment variable so your function code can read it.
In your Functions container app, under Application, select Revisions and replicas.
Select Create new revision.
In the Container tab, select your container, and then select Edit.
Select the Environment variables tab, and then select Add.
Enter the following values:
Property Value Name DATABASE_PASSWORDSource Reference a secret Value database-passwordSelect Save, and then select Create to deploy the new revision.
Verify the secret
Confirm your function can read the secret value by invoking the function and checking that it runs without errors related to missing configuration.
curl "https://<FUNCTIONS_APP_URL>/api/<FUNCTION_NAME>"
Important
Container Apps injects the secret value into the environment variable at runtime. Your code reads the environment variable and doesn't access the secret store directly.
Limitations
Container Apps secrets have the following limitations:
- No centralization - each container app stores its own secrets separately.
- No automatic rotation - you must update secret values manually.
- No expiration - secrets don't expire automatically.
- Limited audit - basic activity logs only; no detailed secret access auditing.
- No versioning - no built-in secret version history.
- Update behavior - changing a secret doesn't trigger a new revision. You must create a new revision or restart existing revisions to pick up changes.
Use Key Vault references
Key Vault references let your container app pull secrets directly from Azure Key Vault using a managed identity. This approach gives you centralized management, automatic rotation, and compliance-grade auditing.
Step 1: Set up managed identity
Your container app needs a managed identity to authenticate to Key Vault without credentials.
Go to your Functions container app in the Azure portal.
Under Settings, select Identity.
In the System assigned tab, set Status to On.
Select Save, and then select Yes to confirm.
Step 2: Grant Key Vault access
Assign the Key Vault Secrets User role to the managed identity so it can read secrets.
Go to your Key Vault in the Azure portal.
Under Settings, select Access control (IAM).
Select Add > Add role assignment.
On the Role tab, select Key Vault Secrets User.
Select Next.
On the Members tab, select Managed identity, and then select Select members.
In the Select managed identities pane, select your subscription, choose Container App for the managed identity type, select your Functions container app, and then select Select.
Select Review + assign.
Step 3: Store a secret in Key Vault
In your Key Vault, under Objects, select Secrets.
Select Generate/Import.
Enter the following values:
Property Value Upload options Manual Name A secret name, for example DatabasePassword.Value Your secret value. Select Create.
Select your newly created secret, then select the current version.
Copy the Secret Identifier URI. Use the versionless URI (without the trailing version segment) to enable automatic rotation.
Step 4: Reference the Key Vault secret in Container Apps
Create a Container Apps secret that references the Key Vault secret, then bind it to an environment variable.
Go to your Functions container app. Under Settings, select Secrets.
Select Add.
In Add secret, enter the following values:
Property Value Name database-passwordType Key Vault reference Key Vault secret URL The Secret Identifier URI you copied. Identity System assigned (or your user-assigned identity). Select Add.
Under Application, select Revisions and replicas. Create a new revision with the environment variable
DATABASE_PASSWORDreferencing thedatabase-passwordsecret.
Step 5: Verify the Key Vault reference
Invoke your function and confirm it runs without errors related to missing configuration.
curl "https://<FUNCTIONS_APP_URL>/api/<FUNCTION_NAME>"
Automatic secret rotation
When you reference a Key Vault secret with a versionless URI, Container Apps automatically retrieves the latest version:
- Versionless URI:
https://myvault.vault.azure.net/secrets/mysecret- always uses the latest version. - Versioned URI:
https://myvault.vault.azure.net/secrets/mysecret/ec96f020...- pinned to a specific version.
With versionless URIs, Container Apps checks for new versions within 30 minutes and automatically restarts active revisions to pick up the new value.