Azure PowerShell을 사용하여 Azure 역할 할당 나열

Azure RBAC(Azure 역할 기반 액세스 제어)는 Azure 리소스에 대한 액세스를 관리하는 데 사용하는 권한 부여 시스템입니다. 사용자, 그룹, 서비스 주체 또는 관리 ID가 액세스할 수 있는 리소스를 확인하기 위해 해당 역할 할당을 나열합니다. 이 문서에서는 Azure PowerShell을 사용하여 역할 할당을 나열하는 방법을 설명합니다.

참고 항목

Azure Az PowerShell 모듈을 사용하여 Azure와 상호 작용하는 것이 좋습니다. 시작하려면 Azure PowerShell 설치를 참조하세요. Az PowerShell 모듈로 마이그레이션하는 방법에 대한 자세한 내용은 Azure PowerShell을 AzureRM에서 Azure로 마이그레이션을 참조하세요.

참고 항목

조직에서 Azure Lighthouse를 사용하는 서비스 공급자에 대해 아웃소싱된 관리 기능을 사용하는 경우 해당 서비스 공급자가 승인한 역할 할당은 여기에 표시되지 않습니다. 마찬가지로 서비스 공급자 테넌트의 사용자는 할당된 역할에 관계없이 고객 테넌트의 사용자에 대한 역할 할당을 볼 수 없습니다.

필수 조건

현재 구독에 대한 역할 할당 나열

현재 구독에서 모든 역할 할당(루트 및 관리 그룹에서 상속된 역할 할당 포함)의 목록을 가져오는 가장 쉬운 방법은 매개 변수 없이 Get-AzRoleAssignment를 사용하는 것입니다.

Get-AzRoleAssignment
PS C:\> Get-AzRoleAssignment

RoleAssignmentId   : /subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleAssignments/11111111-1111-1111-1111-111111111111
Scope              : /subscriptions/00000000-0000-0000-0000-000000000000
DisplayName        : Alain
SignInName         : alain@example.com
RoleDefinitionName : Storage Blob Data Reader
RoleDefinitionId   : 2a2b9908-6ea1-4ae2-8e65-a410df84e7d1
ObjectId           : 44444444-4444-4444-4444-444444444444
ObjectType         : User
CanDelegate        : False

RoleAssignmentId   : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/pharma-sales/providers/Microsoft.Authorization/roleAssignments/33333333-3333-3333-3333-333333333333
Scope              : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/pharma-sales
DisplayName        : Marketing
SignInName         :
RoleDefinitionName : Contributor
RoleDefinitionId   : b24988ac-6180-42a0-ab88-20f7382dd24c
ObjectId           : 22222222-2222-2222-2222-222222222222
ObjectType         : Group
CanDelegate        : False

...

구독의 역할 할당 나열

구독 범위에서 모든 역할 할당을 나열하려면 Get-AzRoleAssignment를 사용합니다. 구독 ID를 가져오려면 Azure Portal의 구독 블레이드에서 확인하거나 Get-AzSubscription을 사용할 수 있습니다.

Get-AzRoleAssignment -Scope /subscriptions/<subscription_id>
PS C:\> Get-AzRoleAssignment -Scope /subscriptions/00000000-0000-0000-0000-000000000000

사용자에 대한 역할 할당 목록

지정된 사용자에 할당된 모든 역할을 나열하려면 Get-AzRoleAssignment를 사용합니다.

Get-AzRoleAssignment -SignInName <email_or_userprincipalname>
PS C:\> Get-AzRoleAssignment -SignInName isabella@example.com | FL DisplayName, RoleDefinitionName, Scope

DisplayName        : Isabella Simonsen
RoleDefinitionName : BizTalk Contributor
Scope              : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/pharma-sales

To list all the roles that are assigned to a specified user and the roles that are assigned to the groups to which the user belongs, use Get-AzRoleAssignment.

Get-AzRoleAssignment -SignInName <email_or_userprincipalname> -ExpandPrincipalGroups
Get-AzRoleAssignment -SignInName isabella@example.com -ExpandPrincipalGroups | FL DisplayName, RoleDefinitionName, Scope

리소스 그룹에 대한 역할 할당 목록

리소스 그룹 범위에서 모든 역할 할당을 나열하려면 Get-AzRoleAssignment를 사용합니다.

Get-AzRoleAssignment -ResourceGroupName <resource_group_name>
PS C:\> Get-AzRoleAssignment -ResourceGroupName pharma-sales | FL DisplayName, RoleDefinitionName, Scope

DisplayName        : Alain Charon
RoleDefinitionName : Backup Operator
Scope              : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/pharma-sales

DisplayName        : Isabella Simonsen
RoleDefinitionName : BizTalk Contributor
Scope              : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/pharma-sales

DisplayName        : Alain Charon
RoleDefinitionName : Virtual Machine Contributor
Scope              : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/pharma-sales

관리 그룹의 역할 할당 나열

관리 그룹 범위에서 모든 역할 할당을 나열하려면 Get-AzRoleAssignment를 사용합니다. 관리 그룹 ID를 가져오려면 Azure Portal의 관리 그룹 블레이드에서 확인하거나 Get-AzManagementGroup을 사용할 수 있습니다.

Get-AzRoleAssignment -Scope /providers/Microsoft.Management/managementGroups/<group_id>
PS C:\> Get-AzRoleAssignment -Scope /providers/Microsoft.Management/managementGroups/marketing-group

리소스에 대한 역할 할당 나열

특정 리소스에 대한 역할 할당을 나열하려면 Get-AzRoleAssignment-Scope 매개 변수를 사용합니다. 범위는 리소스에 따라 달라집니다. 범위를 가져오려면 매개 변수 없이 Get-AzRoleAssignment를 실행하여 모든 역할 할당을 나열한 다음 나열하려는 범위를 찾을 수 있습니다.

Get-AzRoleAssignment -Scope "/subscriptions/<subscription_id>/resourcegroups/<resource_group_name>/providers/<provider_name>/<resource_type>/<resource>

This following example shows how to list the role assignments for a storage account. Note that this command also lists role assignments at higher scopes, such as resource groups and subscriptions, that apply to this storage account.

PS C:\> Get-AzRoleAssignment -Scope "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/storage-test-rg/providers/Microsoft.Storage/storageAccounts/storagetest0122"

If you want to just list role assignments that are assigned directly on a resource, you can use the Where-Object command to filter the list.

PS C:\> Get-AzRoleAssignment | Where-Object {$_.Scope -eq "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/storage-test-rg/providers/Microsoft.Storage/storageAccounts/storagetest0122"}

클래식 서비스 관리자 및 공동 관리자에 대한 역할 할당 나열

클래식 구독 관리자 및 공동 관리자에 대한 역할 할당을 나열하려면 Get-AzRoleAssignment를 사용합니다.

Get-AzRoleAssignment -IncludeClassicAdministrators

관리 ID에 대한 역할 할당 나열

다음 단계를 수행합니다.

  1. 시스템 할당 또는 사용자 할당 관리 ID의 개체 ID를 가져옵니다.

    사용자 할당 관리 ID의 개체 ID를 가져오려면 Get-AzADServicePrincipal을 사용할 수 있습니다.

    Get-AzADServicePrincipal -DisplayNameBeginsWith "<name> or <vmname>"
    
  2. 역할 할당을 나열하려면 Get-AzRoleAssignment를 사용합니다.

    Get-AzRoleAssignment -ObjectId <objectid>
    

다음 단계