Key Vault: move from access policies to Azure RBAC
Key Vault has two permission models. Azure RBAC is the recommended one, and switching is simpler than it looks if you plan the role mapping first.
On this page
Key Vault can control data access with vault access policies (the original model) or Azure RBAC. Microsoft recommends RBAC, and there are good reasons.
Legacy model
- Set on the vault itself
- Whole-vault scope only
- Vault managers can grant themselves data access
- No PIM
Recommended
- Same model as all Azure resources
- Scope to vault or a single secret
- Separates management from data access
- Works with PIM and access reviews
Why RBAC is better
- One model everywhere. Permissions are managed the same way as every other Azure resource, and they appear in the same reviews and reports.
- PIM support. Data-plane roles can be made eligible and time-boxed.
- Finer scope. Roles can be assigned on a single secret, key or certificate, not just the whole vault.
- Separation of duties. With access policies, anyone who can manage the vault can grant themselves access to its secrets. With RBAC, data access needs a role assignment permission they may not have.
Common role mappings
| Role | Use for |
|---|---|
| Key Vault Secrets User | Apps that read secrets |
| Key Vault Crypto User | Apps that use keys to encrypt, decrypt, sign or verify |
| Key Vault Certificate User | Apps that read certificates |
| Key Vault Secrets Officer | People who manage secrets |
| Key Vault Administrator | Full data-plane management. Use sparingly, ideally through PIM. |
Switching over
- List the existing access policies and map each to an RBAC role.
- Create the role assignments before switching. Role assignments can take a few minutes to take effect.
- Switch the permission model:
az keyvault update --name kv-app-prod --resource-group rg-app --enable-rbac-authorization trueWhat each line does
- Line 1: Azure CLI: updates key vaults. Makes a change.
- Test every app that uses the vault. If something breaks, switching back restores the old access policies.
Finding vaults still on access policies
// Azure Resource Graph
resources
| where type == "microsoft.keyvault/vaults"
| extend rbac = tobool(properties.enableRbacAuthorization)
| where rbac != true
| project name, resourceGroup, subscriptionIdPair this with the built-in Azure Policy that audits Key Vaults not using RBAC, so new vaults don't add to the list.
- Map every access policy to a role
- Create role assignments and wait for them to apply
- Switch the permission model
- Test each app and pipeline
- Remove leftover Contributor rights that were only there for access policies
Does switching delete the access policies?
They're kept but ignored while RBAC is on. Switching back makes them active again, which is your rollback.
Who can make the switch?
Changing the permission model needs permission to create role assignments, such as Owner or User Access Administrator, because it changes who can reach the data.