Assign Owner role on multiple resources in azure?

Siva Poreddy 1 Reputation point
2023-01-18T16:44:10.1133333+00:00

Hi All, I have 300+ resource groups in Azure and i want to assign Owner access to 250 resource groups. Individually I have to assign the owner access on each resource group is time consuming task. Is there is any other way to do this?

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
4,598 questions
Azure Active Directory
Azure Active Directory
An Azure enterprise identity service that provides single sign-on and multi-factor authentication.
12,713 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Carlos Solís Salazar 9,986 Reputation points
    2023-01-18T16:59:22.28+00:00

    Thank you for asking this question on the Microsoft Q&A Platform.

    You can automate that task by creating a PowerShell script, for example:

    $RGs = "rg1", "rg2", "rg3"
    $USER = "user@domain.com"
    $RGs | ForEach-Object {
    New-AzRoleAssignment -ResourceGroupName $_ -SignInName $USER -RoleDefinitionName Owner -AllowDelegation
    }
    

    With that script, you can assign the role of the Owner to multiple resources group to one user.

    More info about the command New-AzRoleAssignment

    Hope this helps!


    Accept Answer and Upvote, if any of the above helped, this thread can help others in the community looking for remediation for similar issues.

    NOTE: To answer you as quickly as possible, please mention me in your reply.