Azure CLI를 사용하여 Azure 역할 할당 나열

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

참고 항목

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

필수 조건

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

특정 사용자에 대한 역할 할당을 나열하려면 az role assignment list를 사용합니다.

az role assignment list --assignee {assignee}

By default, only role assignments for the current subscription will be displayed. To view role assignments for the current subscription and below, add the --all parameter. To include role assignments at parent scopes, add the --include-inherited parameter. To include role assignments for groups of which the user is a member transitively, add the --include-groups parameter.

The following example lists the role assignments that are assigned directly to the patlong@contoso.com user:

az role assignment list --all --assignee patlong@contoso.com --output json --query '[].{principalName:principalName, roleDefinitionName:roleDefinitionName, scope:scope}'
[
  {
    "principalName": "patlong@contoso.com",
    "roleDefinitionName": "Backup Operator",
    "scope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/pharma-sales"
  },
  {
    "principalName": "patlong@contoso.com",
    "roleDefinitionName": "Virtual Machine Contributor",
    "scope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/pharma-sales"
  }
]

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

리소스 그룹 범위에 존재하는 역할 할당을 나열하려면 az role assignment list를 사용합니다.

az role assignment list --resource-group {resourceGroup}

The following example lists the role assignments for the pharma-sales resource group:

az role assignment list --resource-group pharma-sales --output json --query '[].{principalName:principalName, roleDefinitionName:roleDefinitionName, scope:scope}'
[
  {
    "principalName": "patlong@contoso.com",
    "roleDefinitionName": "Backup Operator",
    "scope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/pharma-sales"
  },
  {
    "principalName": "patlong@contoso.com",
    "roleDefinitionName": "Virtual Machine Contributor",
    "scope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/pharma-sales"
  },
  
  ...

]

구독의 역할 할당 나열

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

az role assignment list --scope "/subscriptions/{subscriptionId}"

Example:

az role assignment list --scope "/subscriptions/00000000-0000-0000-0000-000000000000" --output json --query '[].{principalName:principalName, roleDefinitionName:roleDefinitionName, scope:scope}'
[
  {
    "principalName": "admin@contoso.com",
    "roleDefinitionName": "Owner",
    "scope": "/subscriptions/00000000-0000-0000-0000-000000000000"
  },
  {
    "principalName": "Subscription Admins",
    "roleDefinitionName": "Owner",
    "scope": "/subscriptions/00000000-0000-0000-0000-000000000000"
  },
  {
    "principalName": "alain@contoso.com",
    "roleDefinitionName": "Reader",
    "scope": "/subscriptions/00000000-0000-0000-0000-000000000000"
  },

  ...

]

관리 그룹의 역할 할당 나열

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

az role assignment list --scope /providers/Microsoft.Management/managementGroups/{groupId}

Example:

az role assignment list --scope /providers/Microsoft.Management/managementGroups/sales-group --output json --query '[].{principalName:principalName, roleDefinitionName:roleDefinitionName, scope:scope}'
[
  {
    "principalName": "admin@contoso.com",
    "roleDefinitionName": "Owner",
    "scope": "/providers/Microsoft.Management/managementGroups/sales-group"
  },
  {
    "principalName": "alain@contoso.com",
    "roleDefinitionName": "Reader",
    "scope": "/providers/Microsoft.Management/managementGroups/sales-group"
  }
]

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

다음 단계를 수행합니다.

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

    사용자 할당 관리 ID의 보안 주체 ID를 가져오려면 az ad sp list 또는 az identity list를 사용할 수 있습니다.

    az ad sp list --display-name "{name}" --query [].id --output tsv
    

    시스템 할당 관리 ID의 보안 주체 ID를 가져오려면 az ad sp list를 사용할 수 있습니다.

    az ad sp list --display-name "{vmname}" --query [].id --output tsv
    
  2. 역할 할당을 나열하려면 az role assignment list를 사용합니다.

    기본적으로 현재 구독에 대한 역할 할당만 표시됩니다. 현재 구독 및 이하에 대한 역할 할당을 보려면 --all 매개 변수를 추가합니다. 상속된 역할 할당을 보려면 --include-inherited 매개 변수를 추가합니다.

    az role assignment list --assignee {objectId}
    

다음 단계