Bird
Raised Fist0
Azurecloud~10 mins

Role-Based Access Control (RBAC) in Azure - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to assign a role to a user in Azure RBAC.

Azure
az role assignment create --assignee [1] --role "Reader" --scope /subscriptions/00000000-0000-0000-0000-000000000000
Drag options to blanks, or click blank then click option'
Auser@example.com
BresourceGroup1
CstorageAccount1
DvirtualMachine1
Attempts:
3 left
💡 Hint
Common Mistakes
Using a resource name instead of a user identifier for --assignee
Confusing the role name with the assignee
2fill in blank
medium

Complete the code to list role assignments for a specific resource group.

Azure
az role assignment list --scope [1]
Drag options to blanks, or click blank then click option'
A/resourceGroups/myResourceGroup
B/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup
C/subscriptions/00000000-0000-0000-0000-000000000000
D/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/virtualMachines/myVM
Attempts:
3 left
💡 Hint
Common Mistakes
Using only the resource group name without subscription path
Using a resource ID for a different resource type
3fill in blank
hard

Fix the error in the command to remove a role assignment by its ID.

Azure
az role assignment delete --ids [1]
Drag options to blanks, or click blank then click option'
A/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleAssignments/abcd1234-5678-90ef-ghij-klmnopqrstuv
BroleAssignmentId
CmyRoleAssignment
D12345
Attempts:
3 left
💡 Hint
Common Mistakes
Using only the GUID without full resource path
Using a friendly name instead of the resource ID
4fill in blank
hard

Fill both blanks to create a custom role definition with permissions.

Azure
{
  "Name": "Custom Reader",
  "IsCustom": true,
  "Description": "Can read resources",
  "Actions": [[1]],
  "NotActions": [[2]]
}
Drag options to blanks, or click blank then click option'
A"Microsoft.Resources/subscriptions/resourceGroups/read"
B"Microsoft.Resources/subscriptions/resourceGroups/write"
C"*"
D"Microsoft.Compute/virtualMachines/start/action"
Attempts:
3 left
💡 Hint
Common Mistakes
Putting write permissions in Actions instead of NotActions
Using wildcards (*) incorrectly
5fill in blank
hard

Fill all three blanks to assign a built-in role to a service principal at subscription scope.

Azure
az role assignment create --assignee [1] --role [2] --scope [3]
Drag options to blanks, or click blank then click option'
A00000000-0000-0000-0000-000000000000
BContributor
C/subscriptions/00000000-0000-0000-0000-000000000000
DmyServicePrincipal@example.com
Attempts:
3 left
💡 Hint
Common Mistakes
Using subscription ID alone without /subscriptions/ prefix for scope
Using role ID instead of role name
Using subscription ID as assignee

Practice

(1/5)
1. What is the main purpose of Role-Based Access Control (RBAC) in Azure?
easy
A. To store data securely
B. To create virtual machines automatically
C. To monitor network traffic
D. To assign permissions to users based on their roles

Solution

  1. Step 1: Understand RBAC concept

    RBAC is designed to control who can do what by assigning roles with specific permissions.
  2. Step 2: Identify the main function

    Assigning permissions based on roles helps manage access securely and efficiently.
  3. Final Answer:

    To assign permissions to users based on their roles -> Option D
  4. Quick Check:

    RBAC controls access by roles = A [OK]
Hint: RBAC = roles control permissions [OK]
Common Mistakes:
  • Confusing RBAC with resource creation
  • Thinking RBAC monitors traffic
  • Assuming RBAC stores data
2. Which of the following is the correct way to assign a role to a user in Azure CLI?
easy
A. az role create --user user@example.com --role Contributor
B. az user assign role --email user@example.com --role Contributor
C. az role assignment create --assignee user@example.com --role Contributor --scope /subscriptions/12345
D. az assign role --user user@example.com --role Contributor

Solution

  1. Step 1: Recall Azure CLI syntax for role assignment

    The correct command uses 'az role assignment create' with --assignee, --role, and --scope parameters.
  2. Step 2: Match the correct command

    az role assignment create --assignee user@example.com --role Contributor --scope /subscriptions/12345 matches the correct syntax and parameters for assigning a role.
  3. Final Answer:

    az role assignment create --assignee user@example.com --role Contributor --scope /subscriptions/12345 -> Option C
  4. Quick Check:

    Correct CLI syntax = D [OK]
Hint: Use 'az role assignment create' with assignee and scope [OK]
Common Mistakes:
  • Using wrong command verbs like 'assign' or 'create' alone
  • Missing the --scope parameter
  • Incorrect parameter names
3. Given this Azure CLI command:
az role assignment create --assignee user@example.com --role Reader --scope /subscriptions/12345/resourceGroups/myGroup

What permission level does the user get on the resource group?
medium
A. Read-only access to the resource group
B. Write access to all resources in the subscription
C. Full control over the subscription
D. No access because scope is incorrect

Solution

  1. Step 1: Analyze the role and scope

    The role is 'Reader', which grants read-only permissions. The scope is a specific resource group, limiting access to that group.
  2. Step 2: Determine permission level

    The user can only read resources inside 'myGroup' resource group, not modify or access other subscription parts.
  3. Final Answer:

    Read-only access to the resource group -> Option A
  4. Quick Check:

    Reader role + resource group scope = read-only access [OK]
Hint: Reader role means read-only at given scope [OK]
Common Mistakes:
  • Assuming Reader grants write or full control
  • Confusing subscription scope with resource group scope
  • Thinking scope is invalid
4. You tried to assign the 'Owner' role to a user but got an error. Which of these is the most likely cause?
medium
A. You do not have permission to assign the Owner role
B. The user email is invalid
C. The role name 'Owner' does not exist
D. You forgot to specify the subscription ID

Solution

  1. Step 1: Understand role assignment permissions

    Assigning the 'Owner' role requires you to have sufficient permissions, usually Owner or User Access Administrator.
  2. Step 2: Identify common error causes

    If you lack permission, Azure blocks the assignment with an error. Other options are less likely because 'Owner' is a valid role and subscription ID is often optional if context is set.
  3. Final Answer:

    You do not have permission to assign the Owner role -> Option A
  4. Quick Check:

    Permission needed to assign Owner role = B [OK]
Hint: Only users with rights can assign Owner role [OK]
Common Mistakes:
  • Assuming role name is wrong
  • Ignoring permission requirements
  • Forgetting subscription context
5. You want to give a service principal permission to manage only virtual machines in a resource group without affecting other resources. Which RBAC role and scope should you assign?
hard
A. Assign 'Contributor' role at the subscription scope
B. Assign 'Virtual Machine Contributor' role at the resource group scope
C. Assign 'Owner' role at the resource group scope
D. Assign 'Reader' role at the virtual machine resource scope

Solution

  1. Step 1: Identify the least privilege role for VM management

    'Virtual Machine Contributor' allows managing VMs but not other resources.
  2. Step 2: Choose the correct scope

    Assigning at the resource group scope limits permissions to that group only, not the whole subscription.
  3. Step 3: Evaluate other options

    'Contributor' at subscription is too broad; 'Owner' is too powerful; 'Reader' only allows viewing, not managing.
  4. Final Answer:

    Assign 'Virtual Machine Contributor' role at the resource group scope -> Option B
  5. Quick Check:

    Least privilege VM management at resource group = A [OK]
Hint: Use specific role + resource group scope for least privilege [OK]
Common Mistakes:
  • Using broad roles like Contributor or Owner unnecessarily
  • Assigning at subscription scope when resource group is enough
  • Choosing Reader role which lacks management permissions
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard