Azure ロールベースのアクセス制御 (Azure RBAC) は、Azure のリソースに対するアクセスを管理するために使用する承認システムです。 ユーザー、グループ、サービスプリンシパル、またはマネージド ID がアクセスできるリソースを特定するには、ロールの割り当てを一覧表示します。 この記事では、Azure CLI を使用してロールの割り当てを一覧表示する方法について説明します。
Note
組織で、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 のロールの割り当ての一覧表示
次のステップを実行します。
システム割り当てまたはユーザー割り当てのマネージド 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
ロールの割り当てを一覧表示するには、az role assignment list を使用します。
既定では、現在のサブスクリプションのロールの割り当てのみが表示されます。 現在のサブスクリプションとその下のロールの割り当てを表示するには、
--all
パラメーターを追加します。 継承されたロールの割り当てを表示するには、--include-inherited
パラメーターを追加します。az role assignment list --assignee {objectId}