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.
| Field | Meaning | Important limit |
|---|---|---|
| Actions | Control plane operations that are allowed | Up to one wildcard in each action string |
| NotActions | Operations subtracted from Actions | This is not a deny; another role can still grant the action |
| DataActions | Data plane operations that are allowed | Roles with DataActions cannot be assigned at management group scope |
| NotDataActions | Data operations subtracted from DataActions | Like NotActions, this is a subtraction |
| AssignableScopes | Where the role may be assigned | Up 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.
Custom role fields
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.
Entra custom roles
Comparing the two
The following comparison summarizes the differences that are most often tested.
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.
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.