A secure C# Web API is hosted on an Azure App Service instance that has a system-assigned managed identity enabled. The Web API needs to retrieve a database connection string stored as a secret in an Azure Key Vault named kv-prod. The Key Vault is configured to use the Azure role-based access control (Azure RBAC) permission model. During testing, the Web API receives a 403 Forbidden error when attempting to retrieve the secret. You need to resolve the authorization issue while adhering to the principle of least privilege. What should you do?
- Assign the Key Vault Secrets User role to the App Service's system-assigned managed identity at the Key Vault scope.Answer
- BCreate a Key Vault access policy in kv-prod that grants Get secret permissions to the App Service's system-assigned managed identity.
- CConfigure an application setting in the App Service that references the secret using the syntax @KeyVault(SecretUri=https://kv-prod.vault.azure.net/secrets/db-conn-string).
- DCreate a user-assigned managed identity, assign the Key Vault Secrets Officer role to it, and configure the App Service to use this identity.
Answer
Assign the Key Vault Secrets User role to the App Service's system-assigned managed identity at the Key Vault scope.
Assigning the Key Vault Secrets User role to the system-assigned managed identity at the Key Vault scope is the correct solution. Since the Key Vault uses the Azure RBAC permission model, traditional access policies are disabled. The Key Vault Secrets User role provides the minimum permissions necessary to retrieve secret values, satisfying the principle of least privilege.
Step-by-Step Solution
Key Concept
Azure Key Vault authorization using the Azure RBAC permission model