Give someone a role with Access control (IAM)
In this task you'll give someone a role on a resource group.
Azure decides what people can do with role assignments. Each one joins three things: who (a user, group or app), what (a role, such as Reader or Contributor) and where (the scope, such as a subscription or a resource group).
Access flows downwards. A role on a subscription applies to every resource group and resource inside it, and a role on a resource group applies to everything in that group.
Example. Ironbridge Payments gives its auditors the Reader role on the whole subscription, so they can look but not change anything, and gives its developers' group Contributor on rg-payments-test only.
Before you start
You need: Owner, User Access Administrator or Role Based Access Control Administrator. Time: 5 minutes.
Where to look
- Resource groups
- rg-portal-practice
- Access control (IAM)
- + Add
- Add role assignment
Steps
- Open rg-portal-practice and select Access control (IAM) in the left menu.
- Select + Add, then Add role assignment.
- On the Role tab, search for Reader and select it.Everyday roles are listed under Job function roles. Powerful ones, such as Owner and Contributor, are on the Privileged administrator roles tab.
- Select Next. On the Members tab, leave the choice as User, group, or service principal and select + Select members.
- Search for a person, select them, then choose Select.No other users yet? Section 4 shows how to create one. For now you can pick your own account just to see how it works.
- Select Review + assign, check the summary, then select Review + assign again.
- Open the Role assignments tab and find the new line under Reader.It can take a few minutes before the new access works for that person.
Commands
# Replace sam@sskaiser.example with a user in your own directory
RG_ID=$(az group show --name rg-portal-practice --query id --output tsv)
# Give the user the Reader role on the group
az role assignment create --assignee sam@sskaiser.example --role Reader --scope $RG_ID
# Remove it again
az role assignment delete --assignee sam@sskaiser.example --role Reader --scope $RG_ID
Watch out for
- Cost
- Role assignments are free.
- Security
- Give the smallest role at the smallest scope that does the job. Where you can, assign roles to groups rather than to people, so access changes when someone joins or leaves the group.
- Common mistakes
- Mixing up Azure roles and Entra roles. Azure roles (this page) control resources. Entra roles, such as User Administrator, control users and the directory, and live in Entra ID (section 4). Also remember that Owner can give access to other people.
Clean up
- rg-portal-practice
- Access control (IAM)
- Role assignments
Tick the assignment you added and select Delete, then confirm. Deleting the resource group also removes assignments made on it, but not ones made on the subscription.
Words to know
- Role
- A named set of permissions. Owner can do everything, Contributor can change resources but not give access, and Reader can only look.
- Scope
- Where a role applies: a management group, a subscription, a resource group or a single resource.
- Security principal
- Whoever gets the role: a user, a group, or an app's identity.
Tick off each step and track your progress in the guide.
Open this task in Azure Portal, Hands On