How To Add User To Azure Resource Group

Recently, I got a requirement to add a few users to one of my critical Azure Resource Groups. In this article, I will walk you through all the steps on how to add user to Resource Group in Azure.

How To Add User To Azure Resource Group

Let us discuss a few simple approaches to do this.

Approach-1: Using Azure Portal

To add user to Azure Resource Group, follow the below steps.

1. Log in to Azure Portal.

2. Search for Resource Groups and click on the search result Resource Groups under Services, as shown below.

Add user to azure resource group

3. Now, click on the specific Resource Group to the one you wish to add the user.

add user to resource group in azure

4. On the specific Resource Group page, Click on the Access Control (IAM) link from the left navigation, and then click on the Add role assignment option from the + Add drop-down, as shown in the screenshot below.

how to add user to resource group in azure

5. Now, select the respective Role from the list and click the Next button as shown below.

add a user to a resource group in azure

6. On the Members tab, Select Assign access to option as User,groups or service principal and then click on the + Select members option. Now, search for and select the user from the list and then click on the Select button, as shown in the screenshot below.

How To Add User To Azure Resource Group

7. Now that the respective member is selected, click on the Next button.

how to add a user to a resource group in azure

8. Now, click on the Review + assign button.

add a user to Azure resource group

Now, the selected user has been added to the Azure Resource Group successfully as shown in the screenshot below.

How to add a user to Azure resource group

Approach-2: Using PowerShell

We can also use the PowerShell command to achieve this. Follow the below steps.

1. Open Windows PowerShell ISE with Run as administrator mode.

how to add user to azure resource group powershell

2. Now, execute the below command to connect to your Azure account.

Connect-AzAccount
how to add user to resource group in azure PowerShell

3. Finally, execute the below PowerShell command to add the specified user to the Azure Resource Group.

New-AzRoleAssignment -SignInName "fewlines4biju_hotmail.com#EXT#@fewlines4bijuhotmail.onmicrosoft.com" `
                     -RoleDefinitionName "Contributor" `
                     -ResourceGroupName "newresgroup"

After executing the above command, the user was added successfully to the specified Resource Group, as shown in the screenshot below.

how to add a user to azure resource group PowerShell

If you wish to add multiple users simultaneously, you can use the below PowerShell command.

$userList = @("fewlines4biju_hotmail.com#EXT#@fewlines4bijuhotmail.onmicrosoft.com", "trp_tsm.com#EXT#@fewlines4bijuhotmail.onmicrosoft.com")
foreach ($user in $userList) {
    New-AzRoleAssignment -SignInName $user `
                         -RoleDefinitionName "Contributor" `
                         -ResourceGroupName "NetworkWatcherRG"
}

After executing the above command, I got the expected output, and both users have been added to the specified Resource Group, as shown in the screenshot below.

how to add user to resource group in azure using PowerShell

Now, to cross-check if the user has been added successfully, we can execute the below command.

Get-AzRoleAssignment -ResourceGroupName "newresgroup"

After executing the above command, I got the expected output as shown in the screenshot below.

Add user to azure resource group powershell

Approach-3: Using Azure CLI

Like the PowerShell command, we can also use the Azure CLI command for this purpose.

We can execute the below Azure CLI command.

az role assignment create --assignee "trp_tsm.com#EXT#@fewlines4bijuhotmail.onmicrosoft.com" --role "Contributor" --scope /subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/resourceGroups/newresgroup

After executing the above command, I got the expected output, and the user has been added to the Resource Group successfully.

how to add user to azure resource group azure cli

Video Tutorial

Conclusion

To add user to Azure Resource Group using the Azure Portal and we can also use the New-AzRoleAssignment PowerShell command to do the same as mentioned in this article.

You may also like following the articles below.

Azure Virtual Machine

DOWNLOAD FREE AZURE VIRTUAL MACHINE PDF

Download our free 25+ page Azure Virtual Machine guide and master cloud deployment today!