You are deploying a web application to multiple Azure App Services in different regions. The applications need to retrieve a database connection string stored in an Azure Key Vault named `kv-checkout-prod`.
The Azure Key Vault is configured to use the Azure role-based access control (Azure RBAC) permission model for authorization. To simplify permission management across all regions and avoid recreating role assignments when App Services are redeployed, you decide to use a single user-assigned managed identity named `id-checkout-prod`.
You need to configure the App Services to retrieve the secret value using this identity while adhering to the principle of least privilege.
Which configuration should you apply?
- AAssign the Key Vault Secrets User role to the system-assigned managed identity of each App Service on the Key Vault, and configure the application setting to `@Microsoft.KeyVault(SecretUri=https://kv-checkout-prod.vault.azure.net/secrets/DbConnectionString/)`.
- BAssign the Key Vault Secrets User role to the `id-checkout-prod` identity on the Key Vault, associate the identity with each App Service, and configure the application setting to `@Microsoft.KeyVault(SecretUri=https://kv-checkout-prod.vault.azure.net/secrets/DbConnectionString/;Identity=id-checkout-prod)`.
- Assign the Key Vault Secrets User role to the `id-checkout-prod` identity on the Key Vault, associate the identity with each App Service, set the `keyVaultReferenceIdentity` property of each App Service to the resource ID of the identity, and configure the application setting to `@Microsoft.KeyVault(SecretUri=https://kv-checkout-prod.vault.azure.net/secrets/DbConnectionString/)`.Answer
- DCreate a Key Vault access policy on `kv-checkout-prod` that grants the Secret Get permission to the `id-checkout-prod` identity, associate the identity with each App Service, set the `keyVaultReferenceIdentity` property of each App Service to the resource ID of the identity, and configure the application setting to `@Microsoft.KeyVault(SecretUri=https://kv-checkout-prod.vault.azure.net/secrets/DbConnectionString/)`.
Answer
To resolve the secret value using a user-assigned identity, you must assign the Key Vault Secrets User role to the user-assigned identity, link it to the App Services, configure each App Service to use that identity for Key Vault references via the keyVaultReferenceIdentity property, and use the correct @Microsoft.KeyVault(SecretUri=...) reference syntax.
Assigning the Key Vault Secrets User role to the user-assigned identity, linking it to the App Services, setting the keyVaultReferenceIdentity property to the identity's resource ID, and using the correct @Microsoft.KeyVault(SecretUri=...) syntax is the correct configuration. This ensures that the App Service uses the user-assigned identity to resolve the Key Vault reference, that the identity has the necessary RBAC permissions to read the secret, and that the reference syntax is valid.
Step-by-Step Solution
Key Concept
Azure App Service Key Vault references with user-assigned managed identities and Azure RBAC authorization.