Skip to content

Intermediate · Microsoft Azure essentials · topic 24 of 50 · 30 min

Microsoft Entra ID and Azure RBAC

Explanation

Microsoft Entra ID (called Azure Active Directory until 2023) is the identity service behind Azure and Microsoft 365: it holds users, groups, service principals and managed identities, and handles sign-in with MFA, passwordless methods and Conditional Access. Azure RBAC then decides what an identity may do with Azure resources: a role assignment joins a security principal, a role definition and a scope, and it is inherited downward.

Two questions: who are you, and what may you do?

Authentication answers "who are you?": proving your identity, for example with a password and a code on your phone. Authorisation answers "what may you do?": read this storage account, restart that VM. In Azure, Microsoft Entra ID handles authentication, and Azure role-based access control (Azure RBAC) handles authorisation for Azure resources.

Microsoft Entra ID is the new name, from 2023, for Azure Active Directory (Azure AD). Many older documents, job posts and exam dumps still say Azure AD; they mean the same service. It is a cloud identity service, not the same thing as the Windows Server Active Directory that runs in office server rooms, although the two are often connected.

Kinds of identities

IdentityWhat it isExample
UserA person who signs inasha@contoso.com
GroupA set of users (or other identities). Assign access to the group, not to each persongrp-web-developers
Service principalAn identity for an application or script, created from an app registration. It signs in with a secret or certificateA CI/CD pipeline that deploys to Azure
Managed identityA service principal that Azure creates and manages for a resource. No secrets for you to store or rotateA VM or Function app reading Key Vault

Managed identities come in two kinds. A system-assigned identity is created for one resource and deleted with it. A user-assigned identity is a separate resource you create once and attach to several resources; it lives until you delete it. Whenever Azure code needs to call another Azure service, prefer a managed identity over a stored secret.

Signing in safely

  • MFA (multi-factor authentication): something you know plus something you have, such as the Microsoft Authenticator app. It stops most password attacks.
  • Passwordless: Authenticator sign-in, passkeys or FIDO2 security keys, and Windows Hello for Business. Nothing to phish.
  • Conditional Access: if-then rules, for example "if the user is an admin, require MFA" or "block sign-ins from outside India for this app". It needs an Entra ID P1 licence or higher.
  • Security defaults: a free, simple baseline that turns on MFA for everyone. Use it if you have no Conditional Access policies.

Azure RBAC: role assignments

A role assignment has three parts. The security principal is who (a user, group, service principal or managed identity). The role definition is what they may do, a list of allowed actions. The scope is where: a management group, a subscription, a resource group or a single resource. Assignments are inherited downward: Reader on a subscription means Reader on every resource group and resource in it.

Built-in roleCan doCannot do
OwnerEverything, including granting access to othersNothing is blocked
ContributorCreate, change and delete all resourcesGrant access to others (assign roles)
ReaderView everythingChange anything
User Access AdministratorManage who has access (role assignments), and readCreate or change other resources

Azure RBAC is additive: if you have Reader from one assignment and Contributor from another, you get both. There are hundreds of narrower built-in roles too, such as Virtual Machine Contributor or Storage Blob Data Reader, and you can write custom roles in JSON.

bash
az role assignment create --assignee asha@contoso.com --role "Reader" \
  --scope "/subscriptions/<subscription-id>/resourceGroups/rg-web"
az role assignment list --assignee asha@contoso.com --all --output table

az vm identity assign --resource-group rg-web --name vm-web-01   # system-assigned managed identity
Give Asha Reader on one resource group, list her assignments, and turn on a VM's managed identity.
json
{
  "Name": "VM Operator (custom)",
  "IsCustom": true,
  "Description": "Can see, start, stop and restart virtual machines.",
  "Actions": [
    "Microsoft.Compute/virtualMachines/read",
    "Microsoft.Compute/virtualMachines/start/action",
    "Microsoft.Compute/virtualMachines/powerOff/action",
    "Microsoft.Compute/virtualMachines/restart/action"
  ],
  "NotActions": [],
  "AssignableScopes": ["/subscriptions/<subscription-id>"]
}
A custom role for a night-shift operator. Create it with: az role definition create --role-definition @vm-operator.json

Entra roles are not Azure roles

There are two separate role systems, and mixing them up is a classic interview question. Microsoft Entra roles, such as Global Administrator or User Administrator, manage the directory: creating users, resetting passwords, registering apps. Azure roles, such as Owner or Reader, manage Azure resources: VMs, networks, storage. A Global Administrator does not automatically get access to subscriptions, although they can choose to elevate their access when needed.

Least privilege and PIM

Least privilege means giving each identity only the access it needs, at the smallest scope, for only as long as needed. Assign roles to groups rather than people, prefer narrow built-in roles over Owner, and choose a resource group scope over a subscription scope where you can.

Privileged Identity Management (PIM) adds just-in-time access. Instead of being Owner all the time, an engineer is "eligible" and activates the role for, say, two hours, with a reason, MFA and sometimes an approval. Every activation is logged. PIM needs Entra ID P2 or Entra ID Governance licences.

Careful: Common mistakes: (1) Making everyone Owner "to save time". Use Contributor or narrower roles, and keep Owner for very few people. (2) Assigning roles to individual users, then forgetting to remove them when people change teams. Use groups. (3) Storing a service principal secret in code. Use a managed identity, or at least Key Vault. (4) Expecting a Global Administrator to see all subscriptions automatically.

Need help?

Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.

Try:

Watch the lesson

Microsoft Entra ID and Azure RBAC · 1/8

Entra ID and Azure RBAC

This lesson covers identity and access in Azure: who you are, and what you are allowed to do.

Prefer a video by a teacher? Find free videos on “microsoft entra id azure rbac role assignment managed identity tutorial” on YouTube ↗

In real life: Access at an IT services company in Chennai

An IT services company manages Azure for a hospital client. Its developers are in an Entra group with Contributor on the non-production subscription and Reader on production. Only two senior engineers are eligible for Owner on production through PIM, for up to four hours with a ticket number. The hospital's auditors get Reader at the management group level, so they see everything and change nothing. The app's Function app uses a system-assigned managed identity with Key Vault Secrets User on one key vault, so no database password lives in code or configuration files.

Practice (0/3 done)

Task 1 · Question

A developer must create and delete VMs in rg-dev but must NOT be able to give anyone else access. Which built-in role at rg-dev fits?

Task 2 · Code · Python

Scopes are written as paths, for example "/mg-college/sub-prod/rg-web/vm-web-01" (a simplified form of real Azure scopes). An assignment is a tuple (principal, role, scope). An assignment applies to a target scope when the target equals the assignment scope or is below it (target starts with scope + "/"). groups maps a user to the groups they belong to; assignments to those groups also apply. Write effective_roles(assignments, principal, scope, groups=None) returning a sorted list of distinct role names, and can(assignments, principal, scope, action, groups=None) returning True if any effective role allows the action, using ROLE_ACTIONS.

Task 3 · Practice

Plan the access for a small startup with 3 developers, 1 tester, 1 finance person and a web app running on an Azure VM that reads secrets from Key Vault. They have one production and one development subscription. Write the groups, roles and scopes you would use, and how the app gets its secrets.

Quick quiz

Question 1

1.What was Microsoft Entra ID called before 2023?

Question 2

2.Which three parts make up an Azure role assignment?

Question 3

3.You give a group Reader on a subscription. What can they read?

Question 4

4.A Function app needs to read a storage account without any stored secret. What should it use?

Question 5

5.What is the difference between Entra roles and Azure roles?

Read more (free)

Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.

What was Microsoft Entra ID called before 2023?

Answer: Azure Active Directory (Azure AD)

Microsoft renamed Azure Active Directory to Microsoft Entra ID in 2023. The service is the same.

Which three parts make up an Azure role assignment?

Answer: Security principal, role definition and scope

Who (security principal), what (role definition) and where (scope).

You give a group Reader on a subscription. What can they read?

Answer: Every resource group and resource in that subscription

Role assignments are inherited by every scope below, including future resources.

A Function app needs to read a storage account without any stored secret. What should it use?

Answer: A managed identity with a narrow data role

A managed identity gets tokens from Entra ID automatically; you then grant it a role such as Storage Blob Data Reader.

What is the difference between Entra roles and Azure roles?

Answer: Entra roles manage the directory (users, apps); Azure roles manage Azure resources

Global Administrator is an Entra role; Owner and Contributor are Azure roles. They are separate systems.

Which Azure built-in role lets someone look but not change?Related

Answer: Reader

Reader gives view-only access.

From Cloud identity and access management

In RBAC, permissions are attached to…Related

Answer: Roles

Roles carry permissions; people are given roles.

From Identity and access management, least privilege and RBAC

Which IAM identity gives temporary credentials and is the right choice for a Lambda function?Related

Answer: IAM role

Lambda runs with an execution role; AWS supplies temporary credentials.

From IAM: users, groups, roles and least privilege

Which Indian Azure region is in Pune?Related

Answer: Central India

Central India is in Pune, South India in Chennai and West India in Mumbai.

From How Azure is organised: tenants, subscriptions and resource groups

Pass the quiz (60% or more) or mark this topic as done when you are ready.

Your progress is saved on this device only.

Next steps

  1. 2 more topics in “Microsoft Azure essentials” before its exam: Azure compute and storage, Azure networking, Functions, databases and monitoring.
  2. Module 6 exam: Microsoft Azure essentials · 13 questions · 20 min, without help. 4 topics of this module still to finish first.
  3. Then the next module, Google Cloud and comparing the clouds. 50 topics left in the course before the final exam.

← Previous: How Azure is organised: tenants, subscriptions and resource groups