Access policies vs RBAC in Azure - Performance Comparison
Start learning this pattern below
Jump into concepts and practice - no test required
We want to understand how the time to check permissions grows when using access policies versus role-based access control (RBAC) in Azure.
How does the system handle more users or resources when deciding access?
Analyze the time complexity of permission checks using access policies and RBAC.
// Access policy check
var isAllowed = CheckAccessPolicy(user, resource);
// RBAC check
var roles = GetUserRoles(user);
var isAllowed = CheckRolePermissions(roles, resource);
This sequence checks if a user can access a resource either by direct access policies or by roles assigned to the user.
Look at what repeats when checking access for many users or resources.
- Primary operation: Checking user permissions via policies or roles.
- How many times: Once per access request, repeated for each user-resource pair.
As the number of users or resources grows, the checks increase accordingly.
| Input Size (n) | Approx. API Calls/Operations |
|---|---|
| 10 | 10 permission checks |
| 100 | 100 permission checks |
| 1000 | 1000 permission checks |
Pattern observation: The number of permission checks grows directly with the number of access requests.
Time Complexity: O(n)
This means the time to check permissions grows linearly with the number of access requests.
[X] Wrong: "Checking access policies or RBAC is instant and does not depend on the number of users or resources."
[OK] Correct: Each access check requires looking up policies or roles, so more users or resources mean more checks and more time.
Understanding how permission checks scale helps you design systems that stay fast as they grow, a key skill in cloud architecture.
"What if we cached user roles after the first check? How would that affect the time complexity of RBAC permission checks?"
Practice
Solution
Step 1: Understand Access Policies
Access Policies give permissions directly on specific resources, like a key vault.Step 2: Understand RBAC
RBAC assigns roles with permissions at different levels like subscription or resource group.Final Answer:
Access Policies grant permissions directly on resources; RBAC assigns roles at scopes. -> Option BQuick Check:
Access Policies = direct resource permissions, RBAC = role-based scopes [OK]
- Confusing Access Policies with RBAC roles
- Thinking RBAC only applies to virtual machines
- Assuming Access Policies control network settings
Solution
Step 1: Identify correct RBAC command
The Azure CLI command to assign RBAC roles is 'az role assignment create' with assignee, role, and scope parameters.Step 2: Verify other options
Other options mention access policies or unrelated commands which are invalid for RBAC role assignment.Final Answer:
az role assignment create --assignee <user> --role <role> --scope <scope> -> Option DQuick Check:
RBAC role assignment uses 'az role assignment create' [OK]
- Using access policy commands for RBAC
- Mixing VM or network commands with RBAC
- Omitting the scope parameter
"permissions": {"keys": ["get", "list"], "secrets": ["get"]}
What permissions does this policy grant?Solution
Step 1: Read the permissions for keys
The keys permission includes 'get' and 'list', so it allows reading and listing keys.Step 2: Read the permissions for secrets
The secrets permission includes only 'get', so it allows reading secrets but no other actions.Final Answer:
Allows getting and listing keys, and getting secrets. -> Option CQuick Check:
Permissions match get/list keys and get secrets [OK]
- Assuming 'get' means create or delete
- Confusing 'list' with full control
- Ignoring secret permissions
Solution
Step 1: Understand RBAC vs Access Policies for Key Vault
Key vault secrets require access policies to grant permissions, RBAC alone may not suffice.Step 2: Analyze the problem
Even if RBAC role is assigned, without an access policy granting secret permissions, access is denied.Final Answer:
The user lacks an access policy granting secret permissions on the key vault. -> Option AQuick Check:
Key vault secret access requires access policies [OK]
- Assuming RBAC alone controls key vault secrets
- Thinking subscription-level RBAC restricts access
- Believing portal restart fixes permission issues
Solution
Step 1: Choose RBAC as best practice
Azure recommends RBAC for Key Vault. Disable access policies and enable RBAC authorization on the Key Vault.Step 2: Assign granular roles at Key Vault scope
Assign 'Key Vault Secrets User' role to user (get/list secrets). Assign 'Key Vault Crypto Officer' role to group (manage keys).Final Answer:
Assign specific RBAC roles to the user for secret read (Key Vault Secrets User) and to the group for key management (Key Vault Crypto Officer). -> Option AQuick Check:
RBAC Secrets User + Crypto Officer roles [OK]
- Trying to mix Access Policies and RBAC (not possible)
- Using access policies for everything (legacy method)
- Assigning overly broad roles or permissions
