Share via

RBAC error on Key Vault Secrets

Venky Swaminathan 0 Reputation points
2026-05-28T00:54:50.67+00:00

I am in a security group that has a role "Key Vaults Secrets Officer" assigned to the key vault resource. But when I perform an azure cli operation to set a secret ('Microsoft.KeyVault/vaults/secrets/setSecret/action') : I get a permission error (Inner error: { "code": "ForbiddenByRbac" }. Why?

Azure Role-based access control
Azure Role-based access control

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.


1 answer

Sort by: Most helpful
  1. AI answer

    2026-05-28T00:55:10.4966667+00:00

    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:

    1. 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 grant setSecret and results in ForbiddenByRbac.
    2. Correct scope and role assignment are required
      Data-plane operations like Microsoft.KeyVault/vaults/secrets/setSecret/action require 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.
    3. 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 with ForbiddenByRbac until propagation completes.
    4. 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 in ForbiddenByRbac.

    To resolve:

    1. Confirm the vault is using Azure role-based access control as the permission model (not “Vault access policy”).
    2. Verify that the Key Vault Secrets Officer role is assigned at the vault (or secret) scope to the security group.
    3. Ensure the CLI identity is indeed a member of that group and run a fresh az login so the token includes the group membership.
    4. Wait a few minutes for RBAC propagation and retry the az keyvault secret set operation.

    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:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.