Lesson 2 of 3 Azure Role-Based Access Control

Managing Custom Azure and Microsoft Entra Roles

This lesson explains how custom roles are defined in both systems, and when they are justified.

Learning outcomes

After completing this lesson, you will be able to:

  • Explain when a custom role is justified.
  • Read an Azure custom role definition.
  • Explain why NotActions is not a deny.
  • Distinguish Azure custom roles from Microsoft Entra custom roles.

When to create a custom role

A custom role adds maintenance work. Someone must own it, review it and update it as services change, so it is justified only when no built-in role fits and when the gap is significant. A typical case is a team that needs to restart virtual machines and read metrics but must not delete them or attach disks. Virtual Machine Contributor is too broad, so a small custom role makes sense. A clone of a similar built-in role with a few actions removed is a sensible starting point.

The first thing to understand is that Azure and Microsoft Entra custom roles are entirely separate. They use different permission sets, are managed in different places, and cannot share permissions.

Azure custom roles

An Azure custom role is a JSON definition. It lists what is allowed on the control plane and data plane, and where the role may be assigned. The following definition allows operators to read, start and restart VMs.

{
  "Name": "Virtual Machine Operator",
  "IsCustom": true,
  "Description": "Read, start and restart virtual machines.",
  "Actions": [
    "Microsoft.Compute/virtualMachines/read",
    "Microsoft.Compute/virtualMachines/start/action",
    "Microsoft.Compute/virtualMachines/restart/action"
  ],
  "NotActions": [],
  "DataActions": [],
  "NotDataActions": [],
  "AssignableScopes": ["/subscriptions/SUB_ID"]
}

The following table explains each field.

FieldMeaningImportant limit
ActionsControl plane operations that are allowedUp to one wildcard in each action string
NotActionsOperations subtracted from ActionsThis is not a deny; another role can still grant the action
DataActionsData plane operations that are allowedRoles with DataActions cannot be assigned at management group scope
NotDataActionsData operations subtracted from DataActionsLike NotActions, this is a subtraction
AssignableScopesWhere the role may be assignedUp to 2,000, not the root scope, and one management group per role

A tenant can hold up to 5,000 custom roles. Microsoft recommends listing actions explicitly instead of using a wildcard, because Microsoft.Compute/* automatically includes operations that are added to the service in future. The NotActions trap appears often in exam questions: a role with * in Actions and Microsoft.Authorization/*/Delete in NotActions does not stop the principal from gaining that right from another role.

Match the pairs

Custom role fields

Exam skills 1.3.6

Match each field of an Azure custom role with its meaning.

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

Microsoft Entra custom roles

A Microsoft Entra custom role uses permissions from the directory, such as microsoft.directory/applications/credentials/update. It is useful for narrow administrative tasks, for example allowing a team to manage the credentials of applications without giving Application Administrator. Built-in directory roles are free, but custom roles require Microsoft Entra ID P1 for every user with a custom role assignment.

A directory role can be assigned at one of three scopes.

  • Tenant: the role applies across the directory.
  • Administrative unit: the role applies to members of the unit, such as the users of one country.
  • Microsoft Entra resource: the role applies to one object, such as a single application or group.

Resource scope is a precise tool. To let a contractor manage one application only, assign a role at that application rather than across the tenant.

Scenario questions

Entra custom roles

Exam skills 1.3.6

Apply Microsoft Entra custom roles and their scopes.

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

Comparing the two

The following comparison summarizes the differences that are most often tested.

Azure custom role
Permission sourceResource provider operations
Defined withJSON, portal, CLI, PowerShell or Bicep
ScopesManagement group, subscription, resource group, resource
LicenceIncluded
PIM eligibleYes
Microsoft Entra custom role
Permission sourcemicrosoft.directory permissions
Defined withMicrosoft Entra admin center, Graph or PowerShell
ScopesTenant, administrative unit, single resource
LicenceP1 for assignees
PIM eligibleYes
Worked example

Reading a role definition

A custom role has Actions of Microsoft.Storage/* and NotActions of Microsoft.Storage/storageAccounts/delete. A user holds this role at a resource group and also holds Contributor at the subscription. Can the user delete a storage account in that resource group?

Yes. NotActions only subtracts from the Actions in that one role definition, and it is not a deny. Contributor at the subscription is inherited and grants the delete action, and RBAC adds the two together.

To prevent the deletion, remove the broader assignment, or use a mechanism that blocks regardless of role, such as a CanNotDelete resource lock or a deny assignment through a deployment stack. Adding the action to NotActions in other custom roles would not help while Contributor remains.

Check yourself

Can a custom role with DataActions be assigned at a management group?

Show answer

No. Roles with DataActions cannot be assigned at management group scope.

Exam Tips

Remember for the exam

  • Azure and Entra custom roles cannot share permissions.
  • NotActions is a subtraction, not a deny.
  • Entra custom roles need P1 for assignees.
  • Roles with DataActions cannot be assigned at management group scope.