How to give an existing Azure user a "global administrator" rights via Azure CLI on tenant level ? (not subscription level)

Ashok Kumar Gupta 5 Reputation points
2022-05-03T07:52:16.15+00:00

How to give an existing Azure user a "global administrator" rights via Azure CLI on tenant level ? (not subscription level)

Microsoft Security Microsoft Entra Microsoft Entra ID
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 46,366 Reputation points
    2022-05-04T01:32:32.777+00:00

    Hi anonymous user

    First, log in to the Azure CLI using the global administrator. Note that you must log in with a global administrator, as only a global administrator can grant administrator roles for users.

    az login  
    

    Next, use the Graph api to grant a tenant-wide global administrator role for your users.

    $Body="{'principalId':'{user object id}', 'roleDefinitionId': '62e90394-69f5-4237-9190-012177145e10', 'directoryScopeId': '/'}"  
    az rest --method POST --uri https://graph.microsoft.com/v1.0/roleManagement/directory/roleAssignments --headers "Content-Type=application/json" --body $Body  
    

    198616-image.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    2 people found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.