Custom Roles

Custom roles are created by combining multiple permissions. For example, a custom role can consist of operations from multiple resources, as follows:

$role = Get-AzureRmRoleDefinition "Virtual Machine Contributor"
$role.Id = $null
$role.Name = "Virtual Machine Operator"
$role.Description = "Can monitor and restart virtual machines."
$role.Actions.Clear()
$role.Actions.Add("Microsoft.Storage/*/read")
$role.Actions.Add("Microsoft.Network/*/read")
$role.Actions.Add("Microsoft.Compute/*/read")
$role.Actions.Add("Microsoft.Compute/virtualMachines/start/action")
    $role.Actions.Add("Microsoft.Compute/virtualMachines/restart/action")
$role.Actions.Add("Microsoft.Authorization/*/read") $role.Actions.Add("Microsoft.Resources/subscriptions/resourceGroups/read") $role.Actions.Add("Microsoft.Insights/alertRules/*") $role.Actions.Add("Microsoft.Support/*") $role.AssignableScopes.Clear() $role.AssignableScopes.Add("/subscriptions/c276fc76-9cd4-44c9-99a7-4fd71546436e") $role.AssignableScopes.Add("/subscriptions/e91d47c4-76f3-4271-a796-21b4ecfe3624") New-AzureRmRoleDefinition -Role $role