I am studying the for this training module:
https://learn.microsoft.com/en-us/training/modules/create-custom-azure-roles-with-rbac/4-manage-custom-roles
I created a custom role in azure portal but I did not save it. I copied the json to a file as is shown below.
When I try to create the role in PowerShell using the exact json I copied from the portal I get this error:
PS C:\temp> New-AzRoleDefinition -InputFile "c:\temp\azure_custom_role.json"
New-AzRoleDefinition : Object reference not set to an instance of an object.
At line:1 char:1
New-AzRoleDefinition -InputFile "c:\temp\azure_custom_role.json"
CategoryInfo : CloseError: (:) [New-AzRoleDefinition], NullReferenceException
FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.NewAzureRoleDefinitionCommand
I have also seen this article.
{ "properties": { "roleName": "Learning - Virtual Machine Contributor", "description": "", "assignableScopes": [ "/subscriptions/555/resourceGroups/Learning_MS_Azure_Training" ], "permissions": [ { "actions": [ "Microsoft.Authorization/*/read", "Microsoft.ClassicCompute/domainNames/*", "Microsoft.ClassicCompute/virtualMachines/*", "Microsoft.ClassicNetwork/reservedIps/link/action", "Microsoft.ClassicNetwork/reservedIps/read", "Microsoft.ClassicNetwork/virtualNetworks/join/action", "Microsoft.ClassicNetwork/virtualNetworks/read", "Microsoft.ClassicStorage/storageAccounts/disks/read", "Microsoft.ClassicStorage/storageAccounts/images/read", "Microsoft.ClassicStorage/storageAccounts/listKeys/action", "Microsoft.ClassicStorage/storageAccounts/read", "Microsoft.Insights/alertRules/*", "Microsoft.ResourceHealth/availabilityStatuses/read", "Microsoft.Resources/deployments/*", "Microsoft.Resources/subscriptions/resourceGroups/read", "Microsoft.Support/*" ], "notActions": [], "dataActions": [], "notDataActions": [] } ] }}