Azure / Azure/azure-powershell
Null reference exception in Get-AzRoleDefinition
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 51
Description
### Description
Running `Get-AzRoleDefinition` errors out in our tenant with:
`Object reference not set to an instance of an object` and no other explanation.
Suspecting a permission issue, still the null reference exception should be handled.
Running with v9.3.0 but reproes also with v10.1
### Issue script & Debug output
```PowerShell
DEBUG: 09:49:20 - GetAzureRoleDefinitionCommand begin processing with ParameterSet 'RoleDefinitionNameParameterSet'.
DEBUG: 09:49:20 - using account id '***'...
DEBUG: 09:49:20 - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 09:49:20 - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True].
Get-AzRoleDefinition: /home/vsts/work/_temp/5308f60e-2704-4df5-8fd3-f7a168939dbf.ps1:10
Line |
10 | Get-AzRoleDefinition
| ~~~~~~~~~~~~~~~~~~~~
| Object reference not set to an instance of an object.
```
### Environment data
```PowerShell
Name Value
---- -----
PSVersion 7.2.13
PSEdition Core
GitCommitId 7.2.13
OS Linux 5.15.0-1041-azure #48-Ubuntu SMP Tue Jun …
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
```
### Module versions
```PowerShell
For more information on account credential management, plea
se visit the following: https://learn.microsoft.com/powersh
ell/azure/authenticate-azureps
Guid : 17a2feff-488b-47f9-8729-e2cec094624c
Version : 2.12.4
ModuleBase : /usr/share/az_9.3.0/Az.Accounts/2.12.4
ModuleType : Script
PrivateData : {PSData}
AccessMode : ReadWrite
ExportedAliases : {[Add-AzAccount, Add-AzAccount], [Get-AzDomain, Get-AzDomai
n], [Invoke-AzRest, Invoke-AzRest], [Login-AzAccount, Login
-AzAccount]…}
ExportedCmdlets : {[Add-AzEnvironment, Add-AzEnvironment], [Clear-AzConfig, C
lear-AzConfig], [Clear-AzContext, Clear-AzContext], [Clear-
AzDefault, Clear-AzDefault]…}
ExportedFunctions : {}
ExportedVariables : {}
NestedModules : {Microsoft.Azure.PowerShell.Cmdlets.Accounts}
```
### Error output
```PowerShell
No output from `Resolve-AzError`
```
Contributor guide
Assessment
This issue has not been assessed yet.