You deploy an Azure App Service web app named app-sales-prod and enable a system-assigned managed identity. You store a database password in an Azure Key Vault named kv-sales-prod.
To reference the secret in the web app, you create an application setting named DbPassword and configure its value as follows:
@Microsoft.KeyVault(SecretUri=https://kv-sales-prod.vault.azure.net/secrets/db-password/)
When testing the application, you notice the secret is not resolved, and the Key Vault reference status displays as 'Access to Key Vault was forbidden'.
Which of the following actions should you perform to resolve this error?
- Assign the 'Key Vault Secrets User' Azure role to the web app's system-assigned managed identity at the key vault scope.Answer
- BUpdate the reference syntax in the application setting by adding the 'UserAssignedIdentity' parameter set to the system-assigned managed identity's resource ID.
- CChange the application setting value to the secret URI without the '@Microsoft.KeyVault' prefix.
- DAssign the 'Key Vault Contributor' Azure role to the web app's system-assigned managed identity at the key vault scope.
Answer
Assign the 'Key Vault Secrets User' Azure role to the web app's system-assigned managed identity at the key vault scope.
To resolve the 'Access to Key Vault was forbidden' error, the managed identity must be granted data plane access to read the secrets. Assigning the 'Key Vault Secrets User' Azure RBAC role at the key vault scope provides the identity with the required permissions to retrieve the secret value.
Step-by-Step Solution
Key Concept
Key Vault References in App Service and authorization using Managed Identities
Estimated Time:1m 30s