-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New-AzRoleAssignment failing with error 'Object reference not set to an instance of an object' in Az.Resources 6.3.0 #19793
Comments
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @darshanhs90, @AshishGargMicrosoft. Issue DetailsDescriptionSP role assignment is failing in the latest version of Az.Resources (6.3.0) module PS C:\WINDOWS\system32> New-AzRoleAssignment -RoleDefinitionName Reader -ApplicationId $sp.AppId
Issue script & Debug outputPS C:\WINDOWS\system32> $DebugPreference = 'Continue'
PS C:\WINDOWS\system32> New-AzRoleAssignment -RoleDefinitionName Reader -ApplicationId $sp.AppId
DEBUG: 1:46:32 PM - NewAzureRoleAssignmentCommand begin processing with ParameterSet 'ScopeWithSPNParameterSet'.
DEBUG: 1:46:32 PM - using account id '<redacted>'...
DEBUG: 1:46:32 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 1:46:32 PM - [ConfigManager] Got [True] from [EnableDataCollection], Module = [], Cmdlet = [].
New-AzRoleAssignment : Object reference not set to an instance of an object.
At line:1 char:1
+ New-AzRoleAssignment -RoleDefinitionName Reader -ApplicationId $sp.Ap ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzRoleAssignment], NullReferenceException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.NewAzureRoleAssignmentCommand
DEBUG: 1:46:32 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: AzureQoSEvent: Module: Az.Resources:6.3.0; CommandName: New-AzRoleAssignment; PSVersion: 5.1.22621.608; IsSuccess: False; Duration: 00:00:00.0450351; Exception: Object reference not
set to an instance of an object.;
DEBUG: 1:46:32 PM - NewAzureRoleAssignmentCommand end processing.
PS C:\WINDOWS\system32> $sp
DisplayName Id AppId
----------- -- -----
test sp 2179d65e-3374-4a74-a7ee-9e08b67ad51d 934a80d1-211e-44ad-91e6-684d8dfade96 Environment dataPS C:\WINDOWS\system32> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.22621.608
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22621.608
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1 Module versionsPS C:\WINDOWS\system32> Get-Module Az*
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 2.10.2 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault...}
Script 6.3.0 Az.Resources {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment...} Error outputPS C:\WINDOWS\system32> Resolve-AzError
DEBUG: 1:49:04 PM - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.
DEBUG: 1:49:04 PM - using account id '<redacted>'...
DEBUG: 1:49:04 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
WARNING: Upcoming breaking changes in the cmdlet 'Resolve-AzError' :
The `Resolve-Error` alias will be removed in a future release. Please change any scripts that use this alias to use `Resolve-AzError` instead.
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: 23
Message : Object reference not set to an instance of an object.
StackTrace : at Microsoft.Azure.Commands.Resources.Models.Authorization.FilterRoleAssignmentsOptions.get_Scope()
at Microsoft.Azure.Commands.Resources.NewAzureRoleAssignmentCommand.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception : System.NullReferenceException
InvocationInfo : {New-AzRoleAssignment}
Line : New-AzRoleAssignment -RoleDefinitionName Reader -ApplicationId $sp.AppId
Position : At line:1 char:1
+ New-AzRoleAssignment -RoleDefinitionName Reader -ApplicationId $sp.Ap ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 23
|
I'm getting the same error using the same module versions but a different parameter set: New-AzRoleAssignment -ResourceGroupName bieno-da12-d-00000-rg -ObjectId "8ef6f3b3-df36-4bbe-89bf-371811e437a9" -RoleDefinitionName Contributor -Debug |
Hello! our build system is also facing the similar issue starting with similar time with other folks here. Failure we get is this:
|
I got the same/very similar errors. Not when I run with a user account from a powershell session (
|
We are fixing this issue. You can expect a hotfix in the next week. |
We have published https://www.powershellgallery.com/packages/Az.Resources/6.3.1. Please try it. Close this issue now. |
Description
SP role assignment is failing in the latest version of Az.Resources (6.3.0) module
PS C:\WINDOWS\system32> New-AzRoleAssignment -RoleDefinitionName Reader -ApplicationId $sp.AppId
New-AzRoleAssignment : Object reference not set to an instance of an object.
At line:1 char:1
Issue script & Debug output
Environment data
Module versions
Error output
The text was updated successfully, but these errors were encountered: