Skip to Content
AzureRBACRole Based Access Control

Role Based Access Control

Azure Role Based Access Control (RBAC) is the authorisation system used to manage access to Azure resources. It allows you to grant users, groups, service principals, and managed identities only the permissions they need, at the appropriate scope.

Key Concepts

  • Security Principal — The identity requesting access: a user, group, service principal, or managed identity
  • Role Definition — A collection of permissions (actions, notActions, dataActions, notDataActions). Azure provides hundreds of built-in roles; custom roles can also be defined
  • Scope — The boundary the role applies to. Scopes form a hierarchy: Management Group → Subscription → Resource Group → Resource
  • Role Assignment — Attaches a role definition to a security principal at a specific scope. Permissions are inherited downward through the scope hierarchy

Scope Hierarchy

Management Group └── Subscription └── Resource Group └── Resource

A role assigned at a higher scope is automatically inherited by all child scopes. For example, a Reader assignment on a subscription grants read access to every resource group and resource within it.

Common Built-in Roles

RoleDescription
OwnerFull access to all resources, including the ability to assign roles
ContributorCreate and manage all resources; cannot assign roles or manage access
ReaderView all resources; cannot make changes
User Access AdministratorManage user access to Azure resources; cannot manage resources themselves
Role Based Access Control AdministratorManage role assignments; cannot manage resources themselves

Usage

# List all role assignments in a resource group Get-AzRoleAssignment -ResourceGroupName "rg-myapp-prod-uks-01" # Assign the Reader role to a user at resource group scope New-AzRoleAssignment ` -SignInName "user@example.com" ` -RoleDefinitionName "Reader" ` -ResourceGroupName "rg-myapp-prod-uks-01" # Assign a role to a security group at subscription scope $group = Get-AzADGroup -DisplayName "MyTeam" New-AzRoleAssignment ` -ObjectId $group.Id ` -RoleDefinitionName "Contributor" ` -Scope "/subscriptions/<sub-id>" # Remove a role assignment Remove-AzRoleAssignment ` -SignInName "user@example.com" ` -RoleDefinitionName "Reader" ` -ResourceGroupName "rg-myapp-prod-uks-01" # List all available built-in role definitions Get-AzRoleDefinition | Where-Object { $_.IsCustom -eq $false } | Select-Object Name, Description | Sort-Object Name

Custom Roles

When built-in roles don’t fit the principle of least privilege, custom roles can be defined with a precise set of permissions.

# Define and create a custom role $role = [Microsoft.Azure.Commands.Resources.Models.Authorization.PSRoleDefinition]::new() $role.Name = "Custom Storage Blob Reader" $role.Description = "Read-only access to blob data" $role.IsCustom = $true $role.Actions = @("Microsoft.Storage/storageAccounts/read") $role.DataActions = @("Microsoft.Storage/storageAccounts/blobServices/containers/blobs/read") $role.AssignableScopes = @("/subscriptions/<sub-id>") New-AzRoleDefinition -Role $role

Best Practices

  • Apply the principle of least privilege — assign only the permissions needed, scoped as narrowly as possible
  • Prefer assigning roles to groups rather than individual users to simplify access management
  • Avoid using Owner at broad scopes; prefer Contributor and grant User Access Administrator separately where needed
  • Use resource group scope as the default; only escalate to subscription or management group scope when explicitly required
  • Regularly audit role assignments using Access Reviews or Azure Policy to remove stale permissions
  • Prefer built-in roles over custom roles where they satisfy least privilege — custom roles add maintenance overhead
  • Avoid assigning roles at the root management group unless enforcing organisation-wide baseline access
Last updated on