Lab 01: Know your access, from scope to Activity log¶
At a glance
- Time: about 30 minutes
- Region: none, you don't create resources in this lab
- You create: nothing
- Clean up: nothing to clean up
What you will learn¶
- Where a resource group sits: tenant, subscription, resource group, resources.
- How Azure role-based access control (RBAC) gives you access: a role, given to a group, at a scope.
- How to read what a role allows, and what happens when you try something it doesn't allow.
- Where to find the record of what happened in your group (the Activity log).
What is different in this environment
Creating management groups, custom roles and role assignments needs permissions that students don't have here, so your trainer demonstrates them. In this lab you explore the access you have, which is set up the same way.
Before you start¶
- You are signed in to the lab directory (Getting started).
- You know your group number
N.
Task 1: Find your place in Azure¶
- In the portal, search for and select Resource groups.
- Select your group,
rg-CLOUD-LAB-GRP-N. - On the Overview page, note:
- the Subscription it belongs to,
- its Location,
- the Tags (if any).
- Select JSON View (top right of the Essentials section) and find the Resource ID. It shows the full path:
/subscriptions/<id>/resourceGroups/rg-CLOUD-LAB-GRP-N.
Think about it
The resource ID is also the scope used by RBAC and Azure Policy. Anything given at this scope applies to every resource inside the group.
Task 2: See who has access¶
- In your resource group, select Access control (IAM).
-
Select View my access. You should see the roles you get through your group:
Role What it gives you Lab StudentCreate and manage the allowed lab resources in this group Lab Student IAM DelegateGive two storage data roles to your own group only (it has a condition) -
Close the pane and select the Role assignments tab.
- Find the
CLOUD-LAB-GRP-Ngroup. Note:- the Role,
- the Scope: This resource (the resource group),
- the Condition column for the IAM Delegate role.
- Look for other assignments in the list, such as the role used by the lab's automatic limit enforcer. Note that you can see them, but you can't change them.
Why a group?
Access is given to your group, not to you as a person. Adding or removing a member changes access without touching the role assignments. This is the recommended way to manage access in Azure.
Task 3: Read what a role allows¶
- Still in Access control (IAM), select the Roles tab.
- Search for
Lab Studentand select View in its row. - On the Permissions tab, browse the list. Then select JSON and find:
actions: what the role allows, for exampleMicrosoft.Compute/virtualMachines/*.notActions: what is taken away again, for exampleMicrosoft.Authorization/*/write.assignableScopes: where the role can be given. It lists the lab resource groups only, not the subscription.
- Compare it with a built-in role: search for Reader and Contributor and view their JSON.
Think about it
- Which line stops you from changing access (IAM)?
- Which line stops you from creating or deleting resource groups?
- Why is
*/readin the list?
Task 4: Try something the role doesn't allow¶
You'll try two actions that the role blocks, and look at the error.
- Add a tag to your resource group: on the Overview page of your group, select Tags (edit), add
owner= your name, and select Apply. - Create a resource group: go to Resource groups, select + Create, enter
rg-test-Nin Southeast Asia, then Review + create and Create.
Both should fail with an error that says you don't have authorization (AuthorizationFailed). For the resource group, the portal may stop you earlier, for example by not offering the subscription or by failing validation. That is the same restriction. Read the message: it names the action that was refused, for example Microsoft.Resources/subscriptions/resourceGroups/write.
Not a guardrail code
These errors don't start with [LAB-...]. They come from RBAC (your role), not from Azure Policy. Lab 02 covers Azure Policy.
Task 5: Check the Activity log¶
- In your resource group, select Activity log.
- Set Timespan to Last hour.
- Find your attempts from Task 4 and select one. The tag attempt is the most likely to be there; an attempt the portal stopped before sending isn't logged. Note the Status (Failed), the Event initiated by (you), and the Operation name.
- Select JSON and find the error message.
Tip
The Activity log is where you, and your trainer, can see who did what in a resource group. It keeps events for 90 days.
Check your work¶
- You can name the subscription and location of your resource group.
- You found the two roles your group has on your resource group.
- You can explain the difference between
actionsandnotActions. - You saw an
AuthorizationFailederror and found it in the Activity log.
Key points¶
- RBAC access = who (security principal) + what (role definition) + where (scope).
- Give roles to groups, at the smallest scope that works.
- A role assignment can have a condition that narrows it further.
- RBAC errors say
AuthorizationFailed. Azure Policy errors in this lab start with[LAB-...]. - The Activity log records every change, including failed attempts.