Skip to content

Commit a3a56ae

Browse files
committed
Update CLI instructions
1 parent ea69a42 commit a3a56ae

File tree

1 file changed

+12
-25
lines changed

1 file changed

+12
-25
lines changed

articles/container-apps/manage-secrets.md

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ az containerapp create \
6969
--name queuereader \
7070
--environment "my-environment-name" \
7171
--image demos/queuereader:v1 \
72-
--secrets "queue-connection-string=$CONNECTION_STRING"
72+
--secrets "queue-connection-string=<CONNECTION_STRING>"
7373
```
7474

75-
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`.
75+
Here, a connection string to a queue storage account is declared in the `--secrets` parameter. Replace `<CONNECTION_STRING>` with the value of your connection string.
7676

7777
# [PowerShell](#tab/powershell)
7878

@@ -101,12 +101,16 @@ Here, a connection string to a queue storage account is declared. The value for
101101

102102
### Reference secret from Key Vault
103103

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.
104+
When you define a secret, you can specify a reference to a secret stored in Azure Key Vault. Container Apps automatically retrieves the secret value from Key Vault and makes it available in your container app's secret.
105+
106+
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.
105107

106108
To enable managed identity in your container app, see [Managed identities](managed-identity.md).
107109

108110
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.
109111

112+
113+
110114
# [ARM template](#tab/arm-template)
111115

112116
Secrets are defined at the application level in the `resources.properties.configuration.secrets` section.
@@ -138,40 +142,23 @@ When you create a container app, secrets are defined using the `--secrets` param
138142

139143
- The parameter accepts a space-delimited set of name/value pairs.
140144
- Each pair is delimited by an equals sign (`=`).
145+
- To specify a Key Vault reference, use the format `<SECRET_NAME>=keyvaultref:<KEY_VAULT_SECRET_URI>,identityref:<MANAGED_IDENTITY_ID>`. For example, `queue-connection-string=keyvaultref:https://mykeyvault.vault.azure.net/secrets/queuereader,identityref:/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/my-identity`.
141146

142147
```bash
143148
az containerapp create \
144149
--resource-group "my-resource-group" \
145150
--name queuereader \
146151
--environment "my-environment-name" \
147152
--image demos/queuereader:v1 \
148-
--secrets "queue-connection-string=$CONNECTION_STRING"
153+
--user-assigned "<USER_ASSIGNED_IDENTITY_ID>" \
154+
--secrets "queue-connection-string=keyvaultref:<KEY_VAULT_SECRET_URI>,identityref:<USER_ASSIGNED_IDENTITY_ID>"
149155
```
150156

151-
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`.
157+
Here, a connection string to a queue storage account is declared in the `--secrets` parameter. Replace `<KEY_VAULT_SECRET_URI>` with the URI of your secret in Key Vault. Replace `<USER_ASSIGNED_IDENTITY_ID>` with the resource ID of the user assigned identity. For system assigned identity, use `System` instead of the resource ID.
152158

153159
# [PowerShell](#tab/powershell)
154160

155-
When you create a container app, secrets are defined as one or more Secret objects that are passed through the `ConfigurationSecrets` parameter.
156-
157-
```azurepowershell
158-
$EnvId = (Get-AzContainerAppManagedEnv -ResourceGroupName my-resource-group -EnvName my-environment-name).Id
159-
$TemplateObj = New-AzContainerAppTemplateObject -Name queuereader -Image demos/queuereader:v1
160-
$SecretObj = New-AzContainerAppSecretObject -Name queue-connection-string -Value $QueueConnectionString
161-
162-
$ContainerAppArgs = @{
163-
Name = 'my-resource-group'
164-
Location = '<location>'
165-
ResourceGroupName = 'my-resource-group'
166-
ManagedEnvironmentId = $EnvId
167-
TemplateContainer = $TemplateObj
168-
ConfigurationSecret = $SecretObj
169-
}
170-
171-
New-AzContainerApp @ContainerAppArgs
172-
```
173-
174-
Here, a connection string to a queue storage account is declared. The value for `queue-connection-string` comes from an environment variable named `$QueueConnectionString`.
161+
Secrets Key Vault references are not supported in PowerShell.
175162

176163
---
177164

0 commit comments

Comments
 (0)