Lesson 2 of 3 Azure Role-Based Access Control

Assigning Roles at the Right Scope

A role assignment joins a principal, a role and a scope. This lesson explains the four scope levels, inheritance and how to choose the narrowest scope.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe the security principals and the four scope levels of Azure RBAC.
  • Explain how role assignments are inherited and where inherited assignments can be removed.
  • Choose the role and scope that meet a requirement with least privilege.

Security principals and scopes

The security principal is a user, a group, a service principal (the identity of an application) or a managed identity (an identity that Azure manages for a resource such as a VM or App Service). The scope is one of four levels, from broadest to narrowest: management group, subscription, resource group and resource. A role assigned at a scope is inherited by all child scopes, so Contributor on a subscription is effective on every resource group and resource in it.

Least privilege therefore means two choices: the role with the fewest permissions that meets the need, and the narrowest scope that covers the resources involved. Assigning roles to groups rather than individual users keeps assignments manageable and within the limit of 4,000 role assignments per subscription.

Put in order

From broadest to narrowest scope

Exam skills 1.2.2

Arrange the four scopes of a role assignment from broadest to narrowest.

Log in to try this activity Interactive activities are free with an account.

Creating and removing assignments

On the scope's Access control (IAM) page, Add role assignment selects the role, the members and, for privileged roles, optional conditions that constrain which roles the assignee may grant. The same is done with az role assignment create --assignee <principal> --role Reader --scope <scope-id> or New-AzRoleAssignment. Assignments take effect within minutes, and a user may need to refresh the portal or sign in again.

An inherited assignment appears on a child scope's Role assignments tab with the scope column showing where it comes from, but it can be removed only at the scope where it was created. Assignments at the root management group are rare and powerful, because they reach every subscription in the tenant. Role assignments made directly on a resource do not move with it to another resource group or subscription, because the resource ID changes, so they must be recreated after the move.

True or false

Working with assignments

Exam skills 1.2.2

Check how role assignments are created, inherited and moved.

Log in to try this activity Interactive activities are free with an account.

Choosing the scope

The following table maps common requirements to the scope that satisfies them with the least privilege.

RequirementScope
Same access in every subscription of a business unitManagement group
Billing reader or security auditor for one subscriptionSubscription
Team manages the resources of one workloadResource group
Application reads one storage account or key vaultResource (or a container within it)

The following diagram places each role assignment for developers, auditors and an application at the scope that grants least privilege.

Role assignments at the right scopes. Contributor for the developers at RG1 and RG2 separately, since an assignment at Sub1 would also cover RG3; Reader for the auditors at Sub1, inherited by every resource group; and Storage Blob Data Reader for the web app's managed identity on the one storage account in RG3.
The scenario is illustrative.
Sort into groups

Choosing the narrowest scope

Exam skills 1.2.2

Choose the narrowest scope that covers each requirement.

Log in to try this activity Interactive activities are free with an account.
Worked example

Choosing role and scope

Subscription Sub1 contains resource groups RG1, RG2 and RG3. The developers group must create and manage resources in RG1 and RG2 only. The auditors group must view all resources in Sub1. A web app's managed identity must read blobs in one storage account in RG3. Which assignments should you create?

Assign Contributor to the developers group at RG1 and at RG2 (two assignments); assigning it at Sub1 would also cover RG3. Assign Reader to the auditors group at Sub1, which is inherited by every resource group. Assign Storage Blob Data Reader to the managed identity at the storage account (or the container), because reading blob data needs a data role and no broader scope is required.

Check yourself

Where must an inherited role assignment be removed?

Show answer

At the scope where it was created, such as the parent subscription or management group; it cannot be removed at the child scope.

Exam Tips

Remember for the exam

  • Assignments are inherited by every child scope.
  • Remove an inherited assignment at the scope where it was created.
  • Assign roles to groups, at the narrowest scope that covers the requirement.
  • Managed identities are assigned roles exactly like users and groups.