Lab 02: Solution - Portal Walkthrough
Only refer to this after attempting the tasks yourself!
Pre-Lab Setup
Creating Resource Groups
- Go to Azure Portal → Search "Resource groups"
- Click + Create
- Configure:
- Subscription: Select yours
- Resource group:
rg-project-dev - Region: East US
- Click Review + create → Create
- Repeat for
rg-project-prod
Creating Storage Account
Go to Storage accounts → + Create
Configure:
- Resource group:
rg-project-dev - Storage account name:
stprojectdev+ random numbers (must be globally unique) - Region: East US
- Performance: Standard
- Redundancy: LRS
- Resource group:
Click Review → Create
After creation, go to the storage account
Click Containers → + Container
Name:
documents, Public access: PrivateClick into the container → Upload → Select any file
Creating Key Vault
Go to Key vaults → + Create
Configure:
- Resource group:
rg-project-dev - Key vault name:
kv-project-dev-+ random numbers - Region: East US
- Pricing tier: Standard
- Resource group:
Click Next: Access configuration
Select Azure role-based access control (important!)
Click Review + create → Create
After creation, go to Key Vault → Secrets → + Generate/Import
Name:
ApiKey, Value:test-secret-123Click Create
Task 1: Understand Role Assignment Components
View Role Assignments
- Go to your Subscription (search "Subscriptions")
- Click your subscription name
- Click Access control (IAM) in left menu
- Click Role assignments tab
Here you'll see all assignments at this scope:
- Note the Role column (Owner, Contributor, etc.)
- Note the Scope column (some may show "Inherited")
- Note the Principal column (users, groups, service principals)
View Role Definition
- Stay in IAM, click Roles tab
- Search for "Contributor"
- Click Contributor → Click Permissions tab
You'll see:
- Actions:
*(everything) - NotActions:
Microsoft.Authorization/*/DeleteMicrosoft.Authorization/*/WriteMicrosoft.Authorization/elevateAccess/Action
This means Contributor can do everything EXCEPT manage role assignments.
Compare Roles
| Role | Key Permissions | Cannot Do |
|---|---|---|
| Reader | View all resources | Create, modify, delete anything |
| Contributor | Create, modify, delete resources | Manage role assignments |
| Owner | Everything | Nothing restricted |
Task 2: Assign Built-in Roles at Resource Group Scope
Assign Reader Role
Go to Resource groups →
rg-project-devClick Access control (IAM)
Click + Add → Add role assignment
Role tab:
- Search for "Reader"
- Select Reader
- Click Next
Members tab:
- Assign access to: User, group, or service principal
- Click + Select members
- Search for your test user (devuser)
- Select and click Select
- Click Next
Review + assign tab:
- Review the assignment
- Click Review + assign
Verify NO Access to Production
- Go to
rg-project-prod→ Access control (IAM) - Click Check access
- Search for your test user
- Should show: NO access at this scope
Task 3: Data Plane vs Control Plane
Test as the User (or check permissions)
Checking what Reader CAN do:
- With Reader on resource group:
- ✅ View storage account in portal
- ✅ View storage account properties
- ❌ View storage account access keys (needs elevated permission)
- ❌ Access blob data (data plane, different permission)
Assign Data Plane Role
- Go to the Storage Account → Access control (IAM)
- Click + Add → Add role assignment
- Role: Search "Storage Blob Data Reader" → Select it
- Members: Select your test user
- Review + assign
Now the user can:
- ✅ View blobs in containers
- ✅ Download blobs
- ❌ Still cannot upload (needs Data Contributor)
- ❌ Still cannot view access keys (control plane)
Task 4: Assign Contributor Role
Add Contributor to Dev Resource Group
- Go to
rg-project-dev→ IAM - + Add → Add role assignment
- Role: Contributor
- Members: Select developer user
- Review + assign
Verify Cannot Assign Roles
- Still in IAM for
rg-project-dev - As the developer user (or check permissions):
- Try to click + Add → Add role assignment
- Will either not appear or give error
- This is because Contributor has
Microsoft.Authorization/*/Writein NotActions
Task 5: Key Vault Access Configuration
Verify RBAC Mode
- Go to Key Vault → Settings → Access configuration
- Ensure Azure role-based access control is selected
- If it shows "Vault access policy", click Azure role-based access control and Save
Assign Key Vault Secrets User
- Go to Key Vault → Access control (IAM)
- + Add → Add role assignment
- Role: Search "Key Vault Secrets User" → Select
- Members: Select test user
- Review + assign
Test Secret Access
- Go to Key Vault → Secrets → Click ApiKey
- Click Show Secret Value
- User with Key Vault Secrets User role can view this
Understanding Key Vault Roles:
| Role | Can Do |
|---|---|
| Key Vault Secrets User | Read secret values |
| Key Vault Secrets Officer | Create, update, delete secrets |
| Key Vault Reader | View Key Vault properties (NOT secret values) |
| Key Vault Contributor | Manage Key Vault settings (NOT secrets) |
Task 6: Create a Custom Role
Create via Portal
Go to Subscription → Access control (IAM)
Click + Add → Add custom role
Basics tab:
- Name:
Virtual Machine Operator - Description:
Can start, stop, and restart VMs. Cannot create or delete. - Baseline permissions: Start from scratch
- Name:
Permissions tab: Click + Add permissions and search for each:
- Search "Microsoft.Compute/virtualMachines/read" → Add
- Search "Microsoft.Compute/virtualMachines/start" → Add the /action
- Search "Microsoft.Compute/virtualMachines/restart" → Add the /action
- Search "Microsoft.Compute/virtualMachines/powerOff" → Add the /action
- Search "Microsoft.Compute/virtualMachines/deallocate" → Add the /action
- Search "Microsoft.Network/*/read" → Add
- Search "Microsoft.Resources/subscriptions/resourceGroups/read" → Add
Assignable scopes tab:
- Should show your subscription
- You can add/remove scopes here
Click Review + create → Create
Assign Custom Role
- Go to
rg-project-dev→ IAM - + Add → Add role assignment
- Your custom role should appear under "Job function roles" tab
- Select Virtual Machine Operator
- Assign to test user
Task 7: Deny Assignments
View Deny Assignments
- Go to Subscription → IAM → Deny assignments tab
- Usually empty unless you're using Azure Blueprints
Understanding Deny Priority
Evaluation Order:
1. Explicit Deny (deny assignment) → BLOCKED
2. Allow (role assignment) → ALLOWED
3. No assignment → DENIED (implicit deny)
Deny ALWAYS wins over Allow!Task 9: Remove and Audit Role Assignments
View Activity Log
- Go to Subscription → Activity log
- Add filter: Operation → Search "role"
- Select:
- Create role assignment
- Delete role assignment
- View entries showing who made changes and when
Export Role Assignments
- Go to Subscription → IAM → Role assignments
- Click Download (top of the list)
- This exports CSV with all assignments
Remove Assignments
- For each test assignment:
- Go to the appropriate scope (subscription/RG)
- IAM → Role assignments
- Find the assignment
- Check the box next to it
- Click Remove → Confirm
Common Mistakes to Avoid
- Assigning at wrong scope - Always double-check you're in the right resource group/subscription
- Forgetting data plane roles - Control plane ≠ Data plane access
- Using Owner when Contributor works - Principle of least privilege
- Not testing as the user - Always verify the assignment works as expected
- Custom role typos - Action strings must be exact