Azure ロールの割り当ての削除

Azure ロールベースのアクセス制御 (Azure RBAC) は、Azure のリソースに対するアクセスを管理するために使用する承認システムです。 Azure リソースからアクセス権を削除するために、ロールの割り当てを削除します。 この記事では、Azure portal、Azure PowerShell、Azure CLI、および REST API を使用して、ロールの割り当てを削除する方法について説明します。

前提条件

ロールの割り当てを削除するには、以下が必要です。

REST API の場合、次のバージョンを使用する必要があります。

  • 2015-07-01 以降

詳細については、Azure RBAC REST API の API バージョンに関するページを参照してください。

Azure Portal

次のステップを実行します。

  1. アクセス権を削除する管理グループ、サブスクリプション、リソース グループ、リソースなどのスコープで [アクセス制御 (IAM)] を開きます。

  2. [ロールの割り当て] タブをクリックして、このスコープのすべてのロールの割り当てを表示します。

  3. ロールの割り当ての一覧で、ロールの割り当てを削除するセキュリティ プリンシパルの隣にチェックマークを追加します。

    削除対象として選択されたロールの割り当てのスクリーンショット。

  4. 削除 をクリックします。

    ロールの割り当ての削除メッセージのスクリーンショット。

  5. ロールの割り当ての削除メッセージが表示されたら、 [はい] をクリックします。

    継承されたロールの割り当てを削除できないというメッセージが表示された場合は、子スコープでロールの割り当てを削除しようとしています。 ロールが割り当てられたスコープでアクセス制御 (IAM) を開き、再試行してください。 [スコープ] 列を確認し、[(継承済み)] の横にあるリンクをクリックすると、正しいスコープでアクセス制御 (IAM) をすばやく開くことができます。

    継承されたロールの割り当てに対するロールの割り当ての削除メッセージのスクリーンショット。

Azure PowerShell

Azure PowerShell では、Remove-AzRoleAssignment を使用してロールの割り当てを削除します。

次の例では、pharma-sales リソース グループの patlong@contoso.com ユーザーから、仮想マシンの共同作成者ロールの割り当てを削除しています。

PS C:\> Remove-AzRoleAssignment -SignInName patlong@contoso.com `
-RoleDefinitionName "Virtual Machine Contributor" `
-ResourceGroupName pharma-sales

Removes the Reader role from the Ann Mack Team group with ID 22222222-2222-2222-2222-222222222222 at a subscription scope.

PS C:\> Remove-AzRoleAssignment -ObjectId 22222222-2222-2222-2222-222222222222 `
-RoleDefinitionName "Reader" `
-Scope "/subscriptions/00000000-0000-0000-0000-000000000000"

Removes the Billing Reader role from the alain@example.com user at the management group scope.

PS C:\> Remove-AzRoleAssignment -SignInName alain@example.com `
-RoleDefinitionName "Billing Reader" `
-Scope "/providers/Microsoft.Management/managementGroups/marketing-group"

Removes the User Access Administrator role with ID 18d7d88d-d35e-4fb5-a5c3-7773c20a72d9 from the principal with ID 33333333-3333-3333-3333-333333333333 at subscription scope with ID 00000000-0000-0000-0000-000000000000.

PS C:\> Remove-AzRoleAssignment -ObjectId 33333333-3333-3333-3333-333333333333 `
-RoleDefinitionId 18d7d88d-d35e-4fb5-a5c3-7773c20a72d9 `
-Scope /subscriptions/00000000-0000-0000-0000-000000000000

If you get the error message: "The provided information does not map to a role assignment", make sure that you also specify the -Scope or -ResourceGroupName parameters. For more information, see Troubleshoot Azure RBAC.

Azure CLI

Azure CLI では、az role assignment delete を使用してロールの割り当てを削除します。

次の例では、pharma-sales リソース グループの patlong@contoso.com ユーザーから、仮想マシンの共同作成者ロールの割り当てを削除しています。

az role assignment delete --assignee "patlong@contoso.com" \
--role "Virtual Machine Contributor" \
--resource-group "pharma-sales"

Removes the Reader role from the Ann Mack Team group with ID 22222222-2222-2222-2222-222222222222 at a subscription scope.

az role assignment delete --assignee "22222222-2222-2222-2222-222222222222" \
--role "Reader" \
--scope "/subscriptions/00000000-0000-0000-0000-000000000000"

Removes the Billing Reader role from the alain@example.com user at the management group scope.

az role assignment delete --assignee "alain@example.com" \
--role "Billing Reader" \
--scope "/providers/Microsoft.Management/managementGroups/marketing-group"

REST API

REST API では、ロールの割り当て - 削除を使用してロールの割り当てを削除します。

  1. ロールの割り当ての識別子 (GUID) を取得します。 この識別子は、ロールの割り当てを最初に作成するときに返されます。あるいは、ロールの割り当てを一覧表示することで取得できます。

  2. 次の要求から開始します。

    DELETE https://management.azure.com/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentId}?api-version=2022-04-01
    
  3. URI の {scope} を、ロールの割り当てを削除するためのスコープに変更します。

    Scope Type
    providers/Microsoft.Management/managementGroups/{groupId1} 管理グループ
    subscriptions/{subscriptionId1} サブスクリプション
    subscriptions/{subscriptionId1}/resourceGroups/myresourcegroup1 Resource group
    subscriptions/{subscriptionId1}/resourceGroups/myresourcegroup1/providers/microsoft.web/sites/mysite1 リソース
  4. {roleAssignmentId} を、ロールの割り当ての GUID 識別子に置き換えます。

    次の要求は、サブスクリプション スコープで指定されたロールの割り当てを削除します。

    DELETE https://management.azure.com/subscriptions/{subscriptionId1}/providers/microsoft.authorization/roleassignments/{roleAssignmentId1}?api-version=2022-04-01
    

    出力例を次に示します。

    {
        "properties": {
            "roleDefinitionId": "/subscriptions/{subscriptionId1}/providers/Microsoft.Authorization/roleDefinitions/a795c7a0-d4a2-40c1-ae25-d81f01202912",
            "principalId": "{objectId1}",
            "principalType": "User",
            "scope": "/subscriptions/{subscriptionId1}",
            "condition": null,
            "conditionVersion": null,
            "createdOn": "2022-05-06T23:55:24.5379478Z",
            "updatedOn": "2022-05-06T23:55:24.5379478Z",
            "createdBy": "{createdByObjectId1}",
            "updatedBy": "{updatedByObjectId1}",
            "delegatedManagedIdentityResourceId": null,
            "description": null
        },
        "id": "/subscriptions/{subscriptionId1}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentId1}",
        "type": "Microsoft.Authorization/roleAssignments",
        "name": "{roleAssignmentId1}"
    }
    

    ARM テンプレート

    Azure Resource Manager テンプレート (ARM テンプレート) を使用してロールの割り当てを削除する方法はありません。 ロールの割り当てを削除するには、Azure portal、Azure PowerShell、Azure CLI、REST API などの他のツールを使用する必要があります。