An Azure service that provides fine-grained access management for Azure resources, enabling you to grant users only the rights they need to perform their jobs.
The error occurs because the identity that runs the Azure CLI does not effectively have the required Key Vault data-plane permission at the scope where the operation is executed, even though the security group is assigned the “Key Vault Secrets Officer” role on the vault.
Key points from the RBAC model for Key Vault:
- Azure RBAC must be enabled for the vault
The new Azure RBAC permission model is an alternative to the legacy access policy model. If the vault is still using the legacy access policy model, data-plane access is controlled by access policies, not by Azure RBAC roles such as “Key Vault Secrets Officer”. In that case, having the RBAC role alone will not grantsetSecretand results inForbiddenByRbac. - Correct scope and role assignment are required
Data-plane operations likeMicrosoft.KeyVault/vaults/secrets/setSecret/actionrequire a Key Vault data role (for example, “Key Vault Secrets Officer”) assigned at a scope that covers the vault or the specific secret. The CLI identity must be:- A member of the group that has the role assignment, and
- Accessing the vault where Azure RBAC is the active permission model.
- Role assignment propagation and caching
Role assignments can take several minutes to propagate. Browsers and portals cache permissions, and a refresh is sometimes required after adding or removing assignments. If the role was just assigned, the CLI call may temporarily fail withForbiddenByRbacuntil propagation completes. - Group-based access and token refresh
When membership in a security group changes, the access token used by Azure CLI may not immediately reflect that membership. A fresh login (az login) is required so that the token includes the updated group claims. Until that happens, Key Vault evaluates the token as if the user is not in the group, resulting inForbiddenByRbac.
To resolve:
- Confirm the vault is using Azure role-based access control as the permission model (not “Vault access policy”).
- Verify that the Key Vault Secrets Officer role is assigned at the vault (or secret) scope to the security group.
- Ensure the CLI identity is indeed a member of that group and run a fresh
az loginso the token includes the group membership. - Wait a few minutes for RBAC propagation and retry the
az keyvault secret setoperation.
If the vault must remain on the legacy access policy model, configure an access policy that grants secret set permissions instead of relying solely on Azure RBAC.
References: