A developer deploys a C# API to an Azure App Service named api-prod. The API retrieves its database password from an Azure Key Vault named kv-prod. The Key Vault's permission model is configured to use Azure role-based access control (Azure RBAC).
To configure the App Service, the developer creates an application setting named DbPassword with the following value:
@Microsoft.KeyVault(SecretUri=https://kv-prod.vault.azure.net/secrets/DbPassword)
After enabling the system-assigned managed identity on api-prod, the developer observes that the API receives a 403 Forbidden error when trying to retrieve the secret.
Which of the following actions should you perform to resolve the secret retrieval failure?
- ACreate a Key Vault access policy in kv-prod that grants the Secret Get permission to the api-prod system-assigned managed identity.
- Assign the Key Vault Secrets User role to the api-prod system-assigned managed identity at the key vault or secret scope.Cevap
- CChange the value of the DbPassword application setting in api-prod to @KeyVault(SecretUri=https://kv-prod.vault.azure.net/secrets/DbPassword).
- DCreate a user-assigned managed identity, assign it the Key Vault Secrets User role, and configure it as the identity of the kv-prod Key Vault itself.
Cevap
Assign the Key Vault Secrets User role to the api-prod system-assigned managed identity at the key vault or secret scope.
Since the Key Vault is configured to use the Azure RBAC permission model, you must use Azure role assignments to authorize access. Assigning the Key Vault Secrets User role to the App Service's system-assigned managed identity allows the application to read the secret value while maintaining least privilege.
Adım Adım Çözüm
Anahtar Kavram
Azure Key Vault authorization using Azure RBAC vs Access Policies for App Service managed identities