liveBook · Manning

Custom role

As explained in Azure Security

A custom role is an authorization configuration that grants a specifically selected set of permissions to users or other identities.

A custom role grants a deliberately selected set of permissions to users or other identities. In Azure RBAC, it supports least-privilege access when built-in roles provide too much access or require combining several roles. section 2.0 section 2.4

Create and assign a custom role with these steps:

  • Choose the smallest required permission set, such as reading virtual machines and restarting them without permitting creation or deletion. section 2.4
  • Define the role in JSON. Put control-plane operations in Actions and NotActions, data-plane operations in DataActions and NotDataActions, and permitted scopes in AssignableScopes. section 2.5
  • Upload the JSON file to Azure Cloud Shell, then run az role definition create --role-definition customRoleDefinition.json. section 2.5
  • Assign the resulting role with az role assignment create, specifying the assignee, role name, and subscription or other supported scope. section 2.5

Restart Virtual Machines

A role can allow reading virtual machines plus start and restart actions at a subscription scope, while leaving NotActions, DataActions, and NotDataActions empty. Assign it to Bob without granting broader built-in roles. section 2.4

{
        "Name": "Restart Virtual Machines",
        "IsCustom": true,
        "Description": "Restart Virtual Machines.",
        "Actions": [
           "Microsoft.Compute/virtualMachines/read",
        "Microsoft.Compute/virtualMachines/start/action",
        "Microsoft.Compute/virtualMachines/restart/action",
        "Microsoft.Resources/subscriptions/resourceGroups/read"
        ],
        "NotActions": [
        ],
        "DataActions": [
        ],
        "NotDataActions": [
        ],
        "AssignableScopes": [
               "/subscriptions/00000000-0000-0000-0000-000000000000"
        ]
}

Inspect the complete JSON definition, including its actions, empty exclusions, and subscription-level assignable scope. section 2.5

How Azure Security covers it

How deep it goes
Explains permission fields, scope selection, JSON creation, Azure CLI commands, assignment, and wildcard risks.
Examples
Uses a Restart Virtual Machines role, JSON permission definitions, Azure CLI commands, and representative creation and assignment output.
What it assumes
Assumes basic Azure identity concepts while introducing authorization, Azure RBAC, custom permissions, and role-definition structure.
What you can do after
Build it from scratch by defining, creating, and assigning a least-privilege Azure RBAC role with JSON and Azure Cloud Shell.
How it connects
Connects authorization with Azure RBAC, least privilege, built-in roles, identity governance, and auditing.

Also explained in

Compare how 3 books explain custom role →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Azure Security. The section links point to the parts of the book it draws on.