When using the New-AzRoleDefinition cmdlet, I'm unable to provide a Role Definition (.json) via the -InputFile parameter, every time it throws an error. The error doesn't indicate if it's an issue with the Cmdlet itself or with the JSON structure.
Error: Object reference not set to an instance of an object.
DEBUG: 15:21:14 - NewAzureRoleDefinitionCommand begin processing with ParameterSet 'InputFileParameterSet'.
DEBUG: 15:21:14 - using account id '[Redacted]'...
New-AzRoleDefinition: Object reference not set to an instance of an object.
DEBUG: AzureQoSEvent: CommandName - New-AzRoleDefinition; IsSuccess - False; Duration - 00:00:00.0220864;; Exception - System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Azure.Commands.Resources.NewAzureRoleDefinitionCommand.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c__3`1.<ExecuteSynchronouslyOrAsJob>b__3_0(T c)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet, Action`1 executor)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet)
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();
DEBUG: Finish sending metric.
DEBUG: 15:21:15 - NewAzureRoleDefinitionCommand end processing.
Error output
WARNING: Breaking changes in the cmdlet 'Resolve-AzError' :
WARNING: - The `Resolve-Error` alias will be removed in a future release. Please change any scripts that use this alias to use `Resolve-AzError` instead.
WARNING: NOTE : Go to https://aka.ms/azps-changewarnings for steps to suppress this breaking change warning, and other information on breaking changes in Azure PowerShell.
HistoryId: 2
Message : Object reference not set to an instance of an object.
StackTrace : at Microsoft.Azure.Commands.Resources.NewAzureRoleDefinitionCommand.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c__3`1.<ExecuteSynchronouslyOrAsJob>b__3_0(T c)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet, Action`1 executor)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet)
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception : System.NullReferenceException
InvocationInfo : {New-AzRoleDefinition}
Line : New-AzRoleDefinition -InputFile "./definition.json"
Position : At line:1 char:1
+ New-AzRoleDefinition -InputFile "./definition.json"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 2
The Azure PowerShell team is listening, please let us know how we are doing: https://aka.ms/azpssurvey?Q_CHL=ERROR.
After making a few minor changes to the .json structure, it seems that the definition is now working, the error message is quite confusing though and could be improved to help the user locate the issue.
Description
When using the
New-AzRoleDefinition
cmdlet, I'm unable to provide a Role Definition (.json) via the -InputFile parameter, every time it throws an error. The error doesn't indicate if it's an issue with the Cmdlet itself or with the JSON structure.Error:
Object reference not set to an instance of an object.
Steps to reproduce
Environment data
Module versions
Debug output
Error output