Skip to content
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 needs allways a ResourceGroup in Scope #22473

Open
andreaszeisler opened this issue Aug 2, 2023 · 2 comments
Open

New-AzRoleAssignment needs allways a ResourceGroup in Scope #22473

andreaszeisler opened this issue Aug 2, 2023 · 2 comments
Labels
ARM - RBAC bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported Service Attention This issue is responsible by Azure service team. Tracking We will track status and follow internally

Comments

@andreaszeisler
Copy link

andreaszeisler commented Aug 2, 2023

Description

I need to assign a role to an objectId with scope that is not a resource group.

I got the following error, because the scope has no resourcegroup in path:
New-AzRoleAssignment: Scope '/subscriptions/<subid>/providers/Microsoft.DocumentDB/locations/westeurope/restorableDatabaseAccounts/<dbaccountid>' should begin with '/subscriptions/<subid>/resourceGroups'.

Subid and dbaccount id are part of my scope.

I like to assign the role CosmosRestoreOperator. This is a role, that can not assign on a scope with a resource group

I looke at the implementation and there was a verification, that "resourcegroups" is needed in scope path.

Issue script & Debug output

New-AzRoleAssignment -ObjectId xxx -RoleDefinitionId 5432c526-bc82-444a-b7ba-57c5b0b5b34f -Scope "/subscriptions/xxxxx/providers/Microsoft.DocumentDB/locations/westeurope/restorableDatabaseAccounts/xxxxx"

Environment data

Name                           Value
----                           -----
PSVersion                      7.3.4
PSEdition                      Core
GitCommitId                    7.3.4
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.12.1                Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}
Script     1.9.1                 Az.CosmosDB                         {Get-AzCosmosDBAccount, Get-AzCosmosDBAccountKey, Get-AzCosmosDBCassandraKeyspace, Get-AzCosmosDBCassandraKeyspaceThroughput…}        
Script     6.3.0                 Az.RecoveryServices                 {Add-AzRecoveryServicesAsrReplicationProtectedItemDisk, Backup-AzRecoveryServicesBackupItem, Copy-AzRecoveryServicesVault, Disable-A… 
Script     6.5.3                 Az.Resources                        {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment…}

Error output

Message        : Scope '/subscriptions/xxxxxxxxxxxxxxx/providers/Microsoft.DocumentDB/locations/westeurope/restorableDatabaseAccounts/xxxxxxxxxxxxxxxxxxxx' should    
                 begin with '/subscriptions/<subid>/resourceGroups'.
StackTrace     :    at Microsoft.Azure.Commands.Resources.Models.Authorization.AuthorizationClient.ValidateScope(String scope, Boolean allowEmpty)
                    at Microsoft.Azure.Commands.Resources.NewAzureRoleAssignmentCommand.ExecuteCmdlet()
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception      : System.ArgumentException
InvocationInfo : {New-AzRoleAssignment}
Line           : New-AzRoleAssignment -ObjectId xxxxxxxxxxxxxxx -RoleDefinitionId 5432c526-bc82-444a-b7ba-57c5b0b5b34f -Scope
                 "/subscriptions/xxxxxxxxxxxxxxxxxxxx/providers/Microsoft.DocumentDB/locations/westeurope/restorableDatabaseAccounts/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Position       : At line:1 char:1
                 + New-AzRoleAssignment -ObjectId xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -
@andreaszeisler andreaszeisler added bug This issue requires a change to an existing behavior in the product in order to be resolved. needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Aug 2, 2023
@ghost ghost added customer-reported and removed needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Aug 2, 2023
@isra-fel isra-fel added the Tracking We will track status and follow internally label Aug 3, 2023
@isra-fel
Copy link
Member

isra-fel commented Aug 3, 2023

@NoriZC please look into this. Thank you.

Copy link
Contributor

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @LizMS, @cbrooksmsft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ARM - RBAC bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported Service Attention This issue is responsible by Azure service team. Tracking We will track status and follow internally
Projects
None yet
Development

No branches or pull requests

3 participants