You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Azure Container Apps allows your application to securely store sensitive configuration values. Once secrets are defined at the application level, secured values are available to container apps. Specifically, you can reference secured values inside scale rules. For information on using secrets with Dapr, refer to [Dapr integration](./dapr-overview.md)
15
+
Azure Container Apps allows your application to securely store sensitive configuration values. Once secrets are defined at the application level, secured values are available to revisions in your container apps. Additionally, you can reference secured values inside scale rules. For information on using secrets with Dapr, refer to [Dapr integration](./dapr-overview.md)
16
16
17
17
- Secrets are scoped to an application, outside of any specific revision of an application.
18
18
- Adding, removing, or changing secrets doesn't generate new revisions.
@@ -26,11 +26,13 @@ An updated or deleted secret doesn't automatically affect existing revisions in
26
26
27
27
Before you delete a secret, deploy a new revision that no longer references the old secret. Then deactivate all revisions that reference the secret.
28
28
29
-
> [!NOTE]
30
-
> Container Apps doesn't support Azure Key Vault integration. Instead, enable managed identity in the container app and use the [Key Vault SDK](../key-vault/general/developers-guide.md) in your app to access secrets.
29
+
## Defining secrets
31
30
31
+
Secrets are defined as a set of name/value pairs. The value of each secret can be specified directly or as a reference to a secret stored in Azure Key Vault.
32
32
33
-
## Defining secrets
33
+
### Store secret value in Container Apps
34
+
35
+
When you define a secret, you can specify its value directly.
34
36
35
37
# [ARM template](#tab/arm-template)
36
38
@@ -97,6 +99,93 @@ Here, a connection string to a queue storage account is declared. The value for
97
99
98
100
---
99
101
102
+
### Reference secret from Key Vault
103
+
104
+
When you define a secret, you can specify a reference to a secret stored in Azure Key Vault. To reference a secret from Key Vault, you must first enable managed identity in your container app and grant the identity access to the Key Vault secrets.
105
+
106
+
To enable managed identity in your container app, see [Managed identities](managed-identity.md).
107
+
108
+
To grant access to Key Vault secrets, [create an access policy](../key-vault/general/assign-access-policy.md) in Key Vault for the managed identity you created. Enable the "Get" secret permission on this policy.
109
+
110
+
# [ARM template](#tab/arm-template)
111
+
112
+
Secrets are defined at the application level in the `resources.properties.configuration.secrets` section.
113
+
114
+
```json
115
+
"resources": [
116
+
{
117
+
...
118
+
"properties": {
119
+
"configuration": {
120
+
"secrets": [
121
+
{
122
+
"name": "queue-connection-string",
123
+
"keyVaultUrl": "<KEY-VAULT-SECRET-URI>",
124
+
"identity": "System"
125
+
}],
126
+
}
127
+
}
128
+
}
129
+
```
130
+
131
+
Here, a connection string to a queue storage account is declared in the `secrets` array. Its value is automatically retrieved from Key Vault using the specified identity. To use a user managed identity, replace `System` with the identity's resource ID.
132
+
133
+
Replace `<KEY-VAULT-SECRET-URI>` with the URI of your secret in Key Vault.
134
+
135
+
# [Azure CLI](#tab/azure-cli)
136
+
137
+
When you create a container app, secrets are defined using the `--secrets` parameter.
138
+
139
+
- The parameter accepts a space-delimited set of name/value pairs.
Here, a connection string to a queue storage account is declared in the `--secrets` parameter. The value for `queue-connection-string` comes from an environment variable named `$CONNECTION_STRING`.
152
+
153
+
# [PowerShell](#tab/powershell)
154
+
155
+
When you create a container app, secrets are defined as one or more Secret objects that are passed through the `ConfigurationSecrets` parameter.
Here, a connection string to a queue storage account is declared. The value for `queue-connection-string` comes from an environment variable named `$QueueConnectionString`.
175
+
176
+
---
177
+
178
+
### Key Vault secret URI and secret rotation
179
+
180
+
The Key Vault secret URI must be in the following format:
181
+
182
+
*`https://myvault.vault.azure.net/secrets/mysecret/ec96f02080254f109c51a1f14cdb1931`: Reference a specific version of a secret.
183
+
*`https://myvault.vault.azure.net/secrets/mysecret`: Reference the latest version of a secret.
184
+
185
+
If a version is not specified in the URI, then the app will use the latest version that exists in the key vault. When newer versions become available, the app will automatically retrieve the latest version within 30 minutes. Any active revisions that reference the secret in an environment variable is automatically restarted to pick up the new value.
186
+
187
+
To force the app to retrieve the latest version of the secret, you can restart a revision.
188
+
100
189
## <aname="using-secrets"></a>Referencing secrets in environment variables
101
190
102
191
After declaring secrets at the application level as described in the [defining secrets](#defining-secrets) section, you can reference them in environment variables when you create a new revision in your container app. When an environment variable references a secret, its value is populated with the value defined in the secret.
0 commit comments