Contoso runs the same application on a virtual machine named vm-app01 and in a container app named ca-app01. Both read secrets from a key vault named kv-app-prod. The subscription contains several other key vaults. All the vaults use the Azure role-based access control permission model.
You need to configure the identity and role assignment for the application. The solution must meet the following requirements:
- Both compute resources must use the same identity, and the identity must remain available when either compute resource is deleted and recreated.
- The identity must read secrets only from kv-app-prod, not from the other vaults in the subscription.
- The identity must not receive any Key Vault permissions beyond reading secrets.
Which configuration should you implement?
Two resources sharing one identity that must survive the resources being recreated points to a user-assigned managed identity, because a system-assigned identity is deleted with its resource. For reading secrets from one vault, the least-privileged choice is Key Vault Secrets User scoped to that specific vault. Assigning it at the subscription would extend access to every vault there, and Key Vault Administrator grants more than reading secrets.
- Correct: A user-assigned managed identity with Key Vault Secrets User assigned at the kv-app-prod scope. A user-assigned identity has an independent lifecycle and can be shared by both resources. Key Vault Secrets User scoped to kv-app-prod reads secrets from that vault only, without broader Key Vault permissions.
- Not correct: A user-assigned managed identity with Key Vault Secrets User assigned at the subscription scope. The identity type and role are correct, but a subscription-scope assignment is inherited by every vault in the subscription, not only kv-app-prod.
- Not correct: A system-assigned managed identity on each resource with Key Vault Secrets User assigned at the kv-app-prod scope. The role and scope are correct, but a system-assigned identity is tied to its resource's lifecycle and is deleted with it, and each resource gets its own separate identity.
- Not correct: A user-assigned managed identity with Key Vault Administrator assigned at the kv-app-prod scope. The identity type and scope are correct, but least privilege calls for Key Vault Secrets User rather than Key Vault Administrator for an identity that only reads secrets; the administrator role grants more than reading secrets.