共用方式為


使用管理群組大規模管理您的 Azure 訂用帳戶

如果您的組織有許多訂用帳戶,則可能需要有效管理這些訂用帳戶的存取權、原則與合規性方法。 Azure 管理群組可以提供訂用帳戶之上的範圍層級。 您可將訂閱組織成稱為「管理群組」的容器,並將治理條件套用到管理群組。 管理群組內的所有訂用帳戶都會自動繼承套用到管理群組的條件。

無論具有何種類型的訂用帳戶,管理群組都可為您提供企業級的大規模管理功能。 若要深入了解管理群組,請參閱使用 Azure 管理群組來組織資源

注意

本文提供關於如何從裝置或服務刪除個人資料的步驟,並且可以用來支援遵循 GDPR 的義務。 如需 GDPR 的一般資訊,請參閱 Microsoft 信任中心的 GDPR 區段服務信任入口網站的 GDPR 區段

重要

Azure Resource Manager 使用者權杖和管理群組快取會持續 30 分鐘,之後系統便會強制加以重新整理。 在進行如移動管理群組或訂用帳戶之類的任何動作,其最多可能需要 30 分鐘才會顯示。 若要更快看見更新,您必須透過重新整理瀏覽器、登入並登出,或是要求新的權杖來更新您的權杖。

針對本文中的 Azure PowerShell 動作,請記住AzManagementGroup相關 Cmdlet 提及 -GroupId-GroupName 參數的別名。 您可以使用其中一個來提供管理群組識別碼作為字串值。

變更管理群組名稱

您可以使用入口網站、Azure PowerShell 或 Azure CLI 來變更管理群組的名稱。

在入口網站中變更名稱

  1. 登入 Azure 入口網站

  2. 選取 [所有服務]>[管理群組]

  3. 選取您想要重新命名的管理群組。

  4. 選取 [詳細資料]

  5. 選取窗格頂端的 [重新命名群組] 選項。

    顯示動作列與 [管理群組] 頁面上的 [重新命名群組] 按鈕的螢幕擷取畫面。

  6. 在 [重新命名群組] 窗格中,輸入您想要顯示的新名稱。

    重新命名管理群組選項的螢幕擷取畫面。

  7. 選取 [儲存]。

在 Azure PowerShell 中變更名稱

若要更新顯示名稱,請在 Azure PowerShell 中使用 Update-AzManagementGroup。 例如,若要將管理群組顯示名稱從 Contoso IT 變更為 Contoso Group,您要執行下列命令:

Update-AzManagementGroup -GroupId 'ContosoIt' -DisplayName 'Contoso Group'

在 Azure CLI 中變更名稱

若為 Azure CLI,請使用 update 命令:

az account management-group update --name 'Contoso' --display-name 'Contoso Group'

刪除管理群組

若要刪除管理群組,您必須符合下列需求:

  • 管理群組下沒有任何子管理群組或訂用帳戶。 若要將訂用帳戶或管理群組移至另一個管理群組,請參閱本文稍後的移動管理群組和訂用帳戶

  • 您必須具備管理群組上的寫入權限 (擁有者、參與者或管理群組參與者)。 若要查看您有哪些權限,請選取管理群組,然後選取 IAM。 若要深入了解 Azure 角色,請參閱什麼是 Azure 角色型存取控制 (Azure RBAC)

在入口網站中刪除管理群組

  1. 登入 Azure 入口網站

  2. 選取 [所有服務]>[管理群組]

  3. 選取您要刪除的管理群組。

  4. 選取 [詳細資料]

  5. 選取 [刪除]

    [刪除] 按鈕之管理群組頁面的螢幕擷取畫面。

    提示

    如果 [刪除] 按鈕無法使用,請將滑鼠停留在按鈕上方會顯示原因。

  6. 對話方塊隨即開啟,並要求您確認要刪除管理群組。

    刪除管理群組確認對話方塊的螢幕擷取畫面。

  7. 選取 [是]

在 Azure PowerShell 中刪除管理群組

若要刪除管理群組,請使用 Azure PowerShell 中的 Remove-AzManagementGroup 命令:

Remove-AzManagementGroup -GroupId 'Contoso'

在 Azure CLI 中刪除管理群組

在 Azure CLI 中,使用 az account management-group delete 命令:

az account management-group delete --name 'Contoso'

檢視管理群組

如果您在管理群組中具有直接或繼承的 Azure 角色,您就可以檢視任何管理群組。

在入口網站中檢視管理群組

  1. 登入 Azure 入口網站

  2. 選取 [所有服務]>[管理群組]

  3. 管理群組階層頁面會顯示。 在此頁面上,您可以探索所有可存取的管理群組和訂用帳戶的位置。 選取群組名稱即可前往階層中的較低層級。 瀏覽方式與檔案總管相同。

  4. 若要查看管理群組的詳細資訊,請選取管理群組標題旁的(詳細資料) 連結。 如果此連結無法使用,表示您沒有檢視該管理群組的權限。

    [管理群組] 頁面的螢幕擷取畫面,其中顯示子管理群組和訂用帳戶。

檢視 Azure PowerShell 中的管理群組

您可以使用 Get-AzManagementGroup 命令來擷取所有群組。 如需管理群組的 GET PowerShell 命令完整清單,請參閱 Az.Resources 模組。

Get-AzManagementGroup

對於單一管理群組的資訊,請使用 -GroupId 參數:

Get-AzManagementGroup -GroupId 'Contoso'

若要傳回特定的管理群組及其底下階層的所有層級,請使用 -Expand-Recurse 參數:

PS C:\> $response = Get-AzManagementGroup -GroupId TestGroupParent -Expand -Recurse
PS C:\> $response

Id                : /providers/Microsoft.Management/managementGroups/TestGroupParent
Type              : /providers/Microsoft.Management/managementGroups
Name              : TestGroupParent
TenantId          : 00000000-0000-0000-0000-000000000000
DisplayName       : TestGroupParent
UpdatedTime       : 2/1/2018 11:15:46 AM
UpdatedBy         : 00000000-0000-0000-0000-000000000000
ParentId          : /providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000
ParentName        : 00000000-0000-0000-0000-000000000000
ParentDisplayName : 00000000-0000-0000-0000-000000000000
Children          : {TestGroup1DisplayName, TestGroup2DisplayName}

PS C:\> $response.Children[0]

Type        : /managementGroup
Id          : /providers/Microsoft.Management/managementGroups/TestGroup1
Name        : TestGroup1
DisplayName : TestGroup1DisplayName
Children    : {TestRecurseChild}

PS C:\> $response.Children[0].Children[0]

Type        : /managementGroup
Id          : /providers/Microsoft.Management/managementGroups/TestRecurseChild
Name        : TestRecurseChild
DisplayName : TestRecurseChild
Children    :

檢視 Azure CLI 中的管理群組

您可以使用 list 命令來擷取所有群組:

az account management-group list

如需單一管理群組的資訊,請使用 show 命令:

az account management-group show --name 'Contoso'

若要傳回特定的管理群組及其底下階層的所有層級,請使用 -Expand-Recurse 參數:

az account management-group show --name 'Contoso' -e -r

移動管理群組和訂用帳戶

建立管理群組的其中一個原因是要將訂用帳戶組合在一起。 只有管理群組和訂用帳戶才能變為另一個管理群組的子群組。 移至管理群組的訂用帳戶會繼承父管理群組中的所有使用者存取權和原則。

您可以在管理群組之間移動訂用帳戶。 訂用帳戶只能有一個父管理群組。

當您將管理群組或訂用帳戶移為另一個管理群組的子系,則有三個規則必須評估為 true。

如果您要執行移動動作,則需要下列每一階層的權限:

  • 子訂用帳戶或管理群組
    • Microsoft.management/managementgroups/write
    • Microsoft.management/managementgroups/subscriptions/write(僅適用於訂用帳戶)
    • Microsoft.Authorization/roleAssignments/write
    • Microsoft.Authorization/roleAssignments/delete
    • Microsoft.Management/register/action
  • 目標父管理群組
    • Microsoft.management/managementgroups/write
  • 目前的父管理群組
    • Microsoft.management/managementgroups/write

例外狀況:如果目標或現有父管理群組是根管理群組,則不適用權限需求。 因為根管理群組是所有新管理群組和訂閱的預設登陸點,所以您不需要其權限即可移動項目。

如果訂閱上的擁有者角色繼承自目前的管理群組,則您的移動目標會受到限制。 您只能將訂閱移至具有「擁有者」角色的另一個管理群組。 因為您會失去訂用帳戶的擁有權,所以無法將其移至您僅為參與者的管理群組。 如果直接將您指派給訂用帳戶的「擁有者」角色,則可以將其移至您是「參與者」的任何管理群組。

若要在 Azure 入口網站中查看您有哪些權限,請選取管理群組,然後選取 [IAM]。 若要深入了解 Azure 角色,請參閱什麼是 Azure 角色型存取控制 (Azure RBAC)?

在入口網站中將現有的訂用帳戶新增到管理群組

  1. 登入 Azure 入口網站

  2. 選取 [所有服務]>[管理群組]

  3. 選取您想要成為父代的管理群組。

  4. 在頁面頂端,選取 [新增訂用帳戶]

  5. 在清單中選取具有正確識別碼的訂用帳戶。

    用來選取現有訂用帳戶的方塊以新增至管理群組的螢幕擷取畫面。

  6. 選取 [儲存]。

在入口網站中從管理群組移除訂用帳戶

  1. 登入 Azure 入口網站

  2. 選取 [所有服務]>[管理群組]

  3. 選取目前為父代的管理群組。

  4. 針對清單中您需要移動的訂用帳戶資料列,選取資料列結尾省略符號 (...)。

    包含訂用帳戶的移動選項功能表的螢幕擷取畫面。

  5. 選取移動

  6. 在 [移動] 窗格上,選取 [新增父管理群組識別碼] 的值。

    將訂用帳戶移至不同管理群組之窗格的螢幕擷取畫面。

  7. 選取 [儲存]。

在 Azure PowerShell 中移動訂用帳戶

若要在 PowerShell 移動訂用帳戶,您可以使用 New-AzManagementGroupSubscription 命令:

New-AzManagementGroupSubscription -GroupId 'Contoso' -SubscriptionId '12345678-1234-1234-1234-123456789012'

若要移除訂用帳戶與管理群組之間的連結,請使用 Remove-AzManagementGroupSubscription 命令:

Remove-AzManagementGroupSubscription -GroupId 'Contoso' -SubscriptionId '12345678-1234-1234-1234-123456789012'

在 Azure CLI 中移動訂用帳戶

若要在 Azure CLI 中移動訂用帳戶,您可以使用 add 命令:

az account management-group subscription add --name 'Contoso' --subscription '12345678-1234-1234-1234-123456789012'

若要從管理群組中移除訂用帳戶,請使用 subscription remove 命令:

az account management-group subscription remove --name 'Contoso' --subscription '12345678-1234-1234-1234-123456789012'

在 ARM 範本中移除訂用帳戶

若要在 Azure Resource Manager 範本 (ARM 範本) 中移動訂用帳戶,請使用下列範本,並將其部署在租用戶層級

{
    "$schema": "https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "targetMgId": {
            "type": "string",
            "metadata": {
                "description": "Provide the ID of the management group that you want to move the subscription to."
            }
        },
        "subscriptionId": {
            "type": "string",
            "metadata": {
                "description": "Provide the ID of the existing subscription to move."
            }
        }
    },
    "resources": [
        {
            "scope": "/",
            "type": "Microsoft.Management/managementGroups/subscriptions",
            "apiVersion": "2020-05-01",
            "name": "[concat(parameters('targetMgId'), '/', parameters('subscriptionId'))]",
            "properties": {
            }
        }
    ],
    "outputs": {}
}

或使用以下 Bicep 檔案:

targetScope = 'managementGroup'

@description('Provide the ID of the management group that you want to move the subscription to.')
param targetMgId string

@description('Provide the ID of the existing subscription to move.')
param subscriptionId string

resource subToMG 'Microsoft.Management/managementGroups/subscriptions@2020-05-01' = {
  scope: tenant()
  name: '${targetMgId}/${subscriptionId}'
}

在入口網站中移除管理群組

  1. 登入 Azure 入口網站

  2. 選取 [所有服務]>[管理群組]

  3. 選取您想要成為父代的管理群組。

  4. 在頁面頂端,選取 [新增管理群組]

  5. 在 [新增管理群組] 窗格中,選擇您是否要使用新的或現有的管理群組:

    • 選取 [建立新增] 建立新的管理群組。
    • 選取 [使用現有項目] 即會顯示您可移至此管理群組之所有管理群組的下拉式清單。

    用於新增管理群組的窗格螢幕擷取畫面。

  6. 選取 [儲存]。

在 Azure PowerShell 中移動管理群組

若要在不同群組下移動管理群組,請在 PowerShell 中使用 Update-AzManagementGroup 命令:

$parentGroup = Get-AzManagementGroup -GroupId ContosoIT
Update-AzManagementGroup -GroupId 'Contoso' -ParentId $parentGroup.id

在 Azure CLI 中移動管理群組

若要在 Azure CLI 中移動管理群組,請使用 update 命令:

az account management-group update --name 'Contoso' --parent ContosoIT

使用活動記錄稽核管理群組

Azure 監視器活動記錄支援管理群組。 您可以在與其他 Azure 資源相同的中央位置,查詢在管理群組中發生的所有事件。 例如,您可以看到對特定的管理群組的所有角色指派或原則指派變更。

與所選管理群組相關的活動記錄和作業螢幕擷取畫面。

要在 Azure 入口網站外部查詢管理群組時,管理群組的目標範圍類似 "/providers/Microsoft.Management/managementGroups/{yourMgID}"

參考來自其他資源提供者的管理群組

當您參考來自另一個資源提供者之動作的管理群組時,請使用下列路徑作為範圍。 當您使用 Azure PowerShell、Azure CLI 和 REST API 時,則適用此路徑。

/providers/Microsoft.Management/managementGroups/{yourMgID}

使用此路徑的一個範例,當您在 Azure PowerShell 中指派新的角色至管理群組時:

New-AzRoleAssignment -Scope "/providers/Microsoft.Management/managementGroups/Contoso"

您可以使用相同的範圍路徑來擷取管理群組的原則定義:

GET https://management.azure.com/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming?api-version=2019-09-01

若要深入了解管理群組,請參閱: