You are configuring an Azure App Service web app named app-orders-prod that must retrieve a database connection string from an Azure Key Vault named kv-orders-prod. The web app is configured with multiple user-assigned managed identities. One of these identities, named id-orders-kv-reader, has the resource ID /subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/rg-prod/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id-orders-kv-reader and has been granted the Key Vault Secrets User role. You need to configure the connection string as an application setting using a Key Vault reference that specifies the correct managed identity. Which of the following app setting values should you use?
- A@Microsoft.KeyVault(SecretUri=https://kv-orders-prod.vault.azure.net/secrets/DbConnectionString/;Identity=id-orders-kv-reader)
- B@Microsoft.KeyVault(SecretUri=https://kv-orders-prod.vault.azure.net/secrets/DbConnectionString/)
- @Microsoft.KeyVault(SecretUri=https://kv-orders-prod.vault.azure.net/secrets/DbConnectionString/;UserAssignedIdentity=/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/rg-prod/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id-orders-kv-reader)Cevap
- D@Azure.KeyVault(SecretUri=https://kv-orders-prod.vault.azure.net/secrets/DbConnectionString/;UserAssignedIdentity=id-orders-kv-reader)
Cevap
The setting value starting with @Microsoft.KeyVault and containing the UserAssignedIdentity parameter with the full resource ID of the managed identity.
The correct app setting value uses the '@Microsoft.KeyVault' prefix, references the secret using its URI ('SecretUri'), and explicitly specifies the resource ID of the user-assigned managed identity via the 'UserAssignedIdentity' parameter. This parameter is required when an App Service has multiple user-assigned managed identities configured, so the App Service knows which identity to use to authenticate against the Key Vault.
Adım Adım Çözüm
Anahtar Kavram
Azure App Service Key Vault References with User-Assigned Managed Identities