Lab 02: Role-Based Access Control (RBAC)
Time: 60 minutes
Difficulty: Intermediate-Advanced
Portal Locations: Azure Portal → Subscriptions/Resource Groups → Access Control (IAM)
Lab Overview
You are the Azure administrator for Contoso Ltd. Multiple teams need access to Azure resources with different permission levels. You must implement the principle of least privilege while ensuring teams can do their jobs.
Pre-Lab Setup
Before starting, create these resources:
Resource Group 1:
rg-project-dev- Location: East US
Resource Group 2:
rg-project-prod- Location: East US
Storage Account:
stprojectdev[random]inrg-project-dev- SKU: Standard LRS
- Create a blob container named
documents - Upload any test file to the container
Key Vault:
kv-project-dev-[random]inrg-project-dev- Create a secret named
ApiKeywith valuetest-secret-123
- Create a secret named
Task 1: Understand Role Assignment Components
Objective
Before making any changes, analyze the existing role assignments in your subscription.
Requirements
Navigate to your subscription's Access Control (IAM) and answer these questions:
List all role assignments at the subscription level
- How many assignments exist?
- What roles are assigned?
- Are any inherited from a management group?
View the definition of the "Contributor" role
- What actions does it ALLOW?
- What actions does it DENY (NotActions)?
- Can a Contributor assign roles to others?
Compare Reader vs Contributor vs Owner
- What is the key difference between each?
Validation
- [ ] You can access IAM → Role assignments at subscription level
- [ ] You can view role definitions and understand Actions/NotActions
- [ ] You understand the inheritance model (Management Group → Subscription → Resource Group → Resource)
Task 2: Assign Built-in Roles at Resource Group Scope
Objective
Grant a user read-only access to the development resource group, but NO access to production.
Requirements
Target User: Use a test user from Lab 01 (or create:
devuser@yourdomain.onmicrosoft.com)Assign Role:
- Role:
Reader - Scope:
rg-project-devonly - NOT at subscription level
- NOT at
rg-project-prod
- Role:
Verify Inheritance:
- Check if the user can see the storage account in
rg-project-dev - Check if the user can see the key vault in
rg-project-dev
- Check if the user can see the storage account in
Validation
- [ ] Role assignment exists on
rg-project-devonly - [ ] User CAN see resources in
rg-project-dev - [ ] User CANNOT see
rg-project-prodat all - [ ] User CANNOT create or modify any resources
Task 3: Data Plane vs Control Plane Permissions
Objective
Understand the critical difference between managing a resource and accessing its data.
Requirements
Current State: User has Reader on
rg-project-devTest Control Plane Access:
- Can the user view storage account properties? (Expected: Yes)
- Can the user view storage account keys? (Expected: No)
- Can the user view Key Vault properties? (Expected: Yes)
Test Data Plane Access:
- Can the user view blobs in the storage container? (Expected: No)
- Can the user view the secret in Key Vault? (Expected: No)
Add Data Plane Permission:
- Assign
Storage Blob Data Readerrole to the user - Scope: Storage account level (not resource group)
- Assign
Re-test Data Plane:
- Can the user now view blobs? (Expected: Yes)
Validation
- [ ] User has Reader (control plane) on resource group
- [ ] User has Storage Blob Data Reader (data plane) on storage account
- [ ] User CAN view blob contents
- [ ] User still CANNOT view storage account keys
- [ ] User still CANNOT view Key Vault secrets (no data plane role assigned)
Task 4: Assign Contributor with Scope Limitation
Objective
Grant a developer the ability to deploy resources, but only to the development environment.
Requirements
Create Second Test User:
developer@yourdomain.onmicrosoft.comAssign Role:
- Role:
Contributor - Scope:
rg-project-dev
- Role:
Verify Permissions:
- User CAN create a new storage account in
rg-project-dev - User CANNOT create anything in
rg-project-prod - User CANNOT assign roles to others (verify this!)
- User CAN create a new storage account in
Validation
- [ ] Developer has Contributor on
rg-project-dev - [ ] Developer CAN create resources in dev
- [ ] Developer CANNOT access prod resource group
- [ ] Developer CANNOT access IAM to assign roles
Task 5: Key Vault Access Configuration
Objective
Configure Key Vault access using Azure RBAC (not access policies).
Requirements
Verify Key Vault Permission Model:
- Open Key Vault → Settings → Access configuration
- Ensure "Azure role-based access control" is selected
- (If using Access policies, switch to RBAC for this lab)
Assign Secret Reader:
- User:
devuser(from Task 2) - Role:
Key Vault Secrets User - Scope: Key Vault resource level
- User:
Test Access:
- User should be able to view the
ApiKeysecret value
- User should be able to view the
Challenge: What if you wanted the user to read secrets but NOT see their values?
- Which role would you use?
Validation
- [ ] Key Vault is using Azure RBAC for permission model
- [ ] User has
Key Vault Secrets Userrole - [ ] User CAN view secret value in portal
- [ ] User CANNOT delete or modify the secret
Task 6: Create a Custom Role
Objective
Create a custom role that allows starting/stopping VMs but nothing else.
Requirements
Create Custom Role Definition:
Name:
Virtual Machine OperatorDescription:
Can start, stop, and restart VMs. Cannot create or delete.Allowed Actions:
Microsoft.Compute/virtualMachines/readMicrosoft.Compute/virtualMachines/start/actionMicrosoft.Compute/virtualMachines/restart/actionMicrosoft.Compute/virtualMachines/powerOff/actionMicrosoft.Compute/virtualMachines/deallocate/actionMicrosoft.Network/*/read(to see network info)Microsoft.Resources/subscriptions/resourceGroups/read
NOT Allowed:
- Cannot delete VMs
- Cannot create VMs
- Cannot modify VM configuration
Assignable Scopes:
- Your subscription only
Assign the Role:
- Assign to a test user at the
rg-project-devscope
- Assign to a test user at the
Validation
- [ ] Custom role appears in role definitions
- [ ] Role can be assigned to users
- [ ] User with role CAN stop/start VMs (create a test VM to verify)
- [ ] User with role CANNOT delete or create VMs
Task 7: Deny Assignments (Conceptual)
Objective
Understand how deny assignments work (even though you cannot create them directly).
Requirements
Research: Navigate to your subscription → IAM → Deny assignments
- Are there any deny assignments?
- Who created them (if any exist)?
Understand the Concept:
- Deny assignments can ONLY be created by Azure Blueprints
- They block access even if a role assignment would allow it
- They are evaluated AFTER allow assignments
Scenario Analysis: A user has:
- Contributor role at subscription level
- Deny assignment that blocks delete operations on
rg-project-prod
Question: Can the user delete resources in
rg-project-prod?
Validation
- [ ] You understand that Deny > Allow
- [ ] You know deny assignments come from Blueprints only
- [ ] Answer to scenario: NO - deny blocks even though Contributor would allow
Task 8: Role Assignment Conditions (Preview)
Objective
Add conditions to a role assignment for more granular control.
Requirements
Assign Storage Blob Data Contributor to a user with conditions:
- User:
developer - Role:
Storage Blob Data Contributor - Scope: Storage account
- User:
Add Condition:
- The user can ONLY access blobs where the blob index tag
projectequalsalpha
- The user can ONLY access blobs where the blob index tag
Test:
- Upload a blob WITH tag
project=alpha→ User should access - Upload a blob WITHOUT that tag → User should NOT access
- Upload a blob WITH tag
Note: This is an advanced feature. Skip if conditions UI is not available in your region.
Validation
- [ ] Role assignment has condition attached
- [ ] Condition enforces tag-based access
- [ ] Access is correctly limited based on blob tags
Task 9: Remove and Audit Role Assignments
Objective
Clean up role assignments and review the audit trail.
Requirements
View Activity Log:
- Navigate to subscription → Activity log
- Filter by Operation: "Create role assignment" and "Delete role assignment"
- Review who made changes and when
Export Role Assignments:
- From IAM, download role assignments as CSV
- Review the export format
Remove Test Assignments:
- Remove all role assignments created during this lab
- Keep only your original admin access
Validation
- [ ] Activity log shows role assignment operations
- [ ] You can export assignments to CSV
- [ ] All test assignments are removed
Cleanup Instructions
- Remove all custom roles created during this lab
- Remove all role assignments to test users
- Delete the test resource groups:
rg-project-devrg-project-prod
- Delete test users (if created specifically for this lab)
Key Concepts Tested
- Role assignment = Principal + Role + Scope
- Scope hierarchy and inheritance
- Control plane vs Data plane permissions
- Built-in roles: Reader, Contributor, Owner
- Custom roles and their limitations
- Key Vault RBAC vs Access Policies
- Activity logging for compliance
- Deny assignments (Blueprints only)