An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.
The difference is caused by the Key Vault permission model in use and by the fact that Contributor is not a data-plane secret management role.
If the vault uses Azure RBAC:
- Creating a secret requires a Key Vault data-plane role such as Key Vault Secrets Officer.
- A subscription Owner or Contributor role does not by itself grant permission to write secrets.
- To assign Key Vault roles, the assigner must have
Microsoft.Authorization/roleAssignments/write, such as Key Vault Data Access Administrator, User Access Administrator, or Owner.
If the vault uses the legacy access policy model:
- Access to secrets is controlled by Key Vault access policies, not by Azure RBAC data-plane roles.
- Users with
Contributor,Key Vault Contributor, or any role includingMicrosoft.KeyVault/vaults/writecan grant themselves data-plane access by configuring a Key Vault access policy. This is why the access policy model is considered less secure. - In troubleshooting guidance, inability to list/get/create secrets is resolved by ensuring the correct Azure RBAC role is assigned, or by using the legacy access policy model correctly if that model is enabled.
Why User B can create secrets while User A cannot:
- If the vault is using access policies, User B may be able to modify the vault configuration at the resource group scope and add or benefit from an access policy that allows secret creation.
- If the vault is using Azure RBAC, User B likely has an explicit Key Vault data-plane role on the vault or inherited at a relevant scope, while User A does not.
- Higher scope
Contributordoes not guarantee secret creation rights because secret creation is a data-plane operation, and control-plane roles do not automatically provide that access.
Recommended configuration:
- Prefer Azure RBAC over access policies for improved security.
- Assign a Key Vault data-plane role such as Key Vault Secrets Officer to both users at the Key Vault scope.
- Use role assignments at the vault scope rather than on individual secrets, except for limited exception scenarios.
- Avoid relying on
Contributorfor secret access.
Portal path for the recommended setup:
- Open the Key Vault.
- Go to Access control (IAM).
- Select Add > Add role assignment.
- Assign Key Vault Secrets Officer to each user.
Example Azure CLI role assignment at vault scope:
az role assignment create --role "Key Vault Secrets Officer" --assignee <user-principal-name> --scope /subscriptions/<subscription-id>/resourcegroups/<resource-group>/providers/Microsoft.KeyVault/vaults/<vault-name>
Important:
- Switching a vault to Azure RBAC invalidates all existing access policy permissions and can cause outages if equivalent Azure roles are not assigned first.
- Assigning roles on individual secrets, keys, or certificates is generally not recommended except for limited scenarios.
References:
- Provide access to Key Vault keys, certificates, and secrets with Azure role-based access control
- Troubleshooting Azure Key Vault access policy issues
- Azure role-based access control (Azure RBAC) vs. access policies (legacy)
- Quickstart: Set and retrieve a secret from Azure Key Vault using PowerShell
- Azure built-in roles for Security