A developer is configuring a web app named prod-orders-app in Azure App Service. The app must retrieve a database password from an Azure Key Vault named orders-vault using a Key Vault reference in the application settings. You have created a user-assigned managed identity named orders-identity and granted it the 'Key Vault Secrets User' role on the Key Vault. You have also associated orders-identity with the web app. Which configuration should you apply to the web app to ensure it successfully retrieves the secret using the user-assigned managed identity?
- ASet the DatabasePassword app setting to @KeyVault(SecretUri=https://orders-vault.vault.azure.net/secrets/db-password/) and configure the web app's key vault reference identity by running az webapp update --name prod-orders-app --resource-group myRG --keyvault-reference-identity <resource-id-of-orders-identity>.
- BSet the DatabasePassword app setting to @Microsoft.KeyVault(SecretUri=https://orders-vault.vault.azure.net/secrets/db-password/) and enable the system-assigned managed identity on the web app, leaving the keyvault-reference-identity configuration parameter unset.
- Set the DatabasePassword app setting to @Microsoft.KeyVault(SecretUri=https://orders-vault.vault.azure.net/secrets/db-password/) and configure the web app's key vault reference identity by running az webapp update --name prod-orders-app --resource-group myRG --keyvault-reference-identity <resource-id-of-orders-identity>.Cevap
- DSet the DatabasePassword app setting to @Microsoft.KeyVault(SecretUri=https://orders-vault.vault.azure.net/secrets/db-password/) and configure the web app's key vault reference identity by running az webapp update --name prod-orders-app --resource-group myRG --keyvault-reference-identity <resource-id-of-orders-identity>, but grant the 'Key Vault Secrets User' role to the App Service's deployment slot principal instead of the managed identity.
Cevap
Set the DatabasePassword app setting to @Microsoft.KeyVault(SecretUri=https://orders-vault.vault.azure.net/secrets/db-password/) and configure the web app's key vault reference identity by running az webapp update --name prod-orders-app --resource-group myRG --keyvault-reference-identity <resource-id-of-orders-identity>.
To successfully resolve a Key Vault reference using a user-assigned managed identity, you must use the correct fully qualified prefix '@Microsoft.KeyVault' and explicitly configure the App Service's 'keyVaultReferenceIdentity' property to the Resource ID of the user-assigned identity. This instructs App Service to use the specific user-assigned identity to perform the runtime call to Key Vault.
Adım Adım Çözüm
Anahtar Kavram
Key Vault references in App Service can be configured to use a user-assigned managed identity by setting the keyVaultReferenceIdentity configuration property to the Resource ID of the identity and using the correct @Microsoft.KeyVault prefix in the application setting.