快速入门:使用 Azure PowerShell 创建管理组Quickstart: Create a management group with Azure PowerShell

管理组是一些容器,可以帮助跨多个订阅管理访问权限、策略和符合性。Management groups are containers that help you manage access, policy, and compliance across multiple subscriptions. 可以创建这些容器来构建可以与 Azure PolicyAzure 基于角色的访问控制配合使用的有效且高效的层次结构。Create these containers to build an effective and efficient hierarchy that can be used with Azure Policy and Azure Role Based Access Controls. 若要详细了解管理组,请参阅使用 Azure 管理组整理资源For more information on management groups, see Organize your resources with Azure management groups.

在目录中创建的第一个管理组可能需要最多 15 分钟才能完成。The first management group created in the directory could take up to 15 minutes to complete. 一些进程会首次运行以在 Azure 中为目录设置管理组服务。There are processes that run the first time to set up the management groups service within Azure for your directory. 在进程完成后将显示通知。You receive a notification when the process is complete. 有关详细信息,请参阅管理组的初始设置For more information, see initial setup of management groups.

先决条件Prerequisites

  • 如果没有 Azure 订阅,请在开始前创建一个试用版订阅帐户。If you don't have an Azure subscription, create a Trial Subscription account before you begin.

  • 在开始之前,请确保安装 Azure PowerShell 的最新版本。Before you start, make sure that the latest version of Azure PowerShell is installed. 有关详细信息,请参阅安装 Azure PowerShell 模块See Install Azure PowerShell module for detailed information.

  • 如果未启用层次结构保护,则租户中的任何 Azure AD 用户都可在未分配有管理组写入权限的情况下创建管理组。Any Azure AD user in the tenant can create a management group without the management group write permission assigned to that user if hierarchy protection isn't enabled. 这个新的管理组成为根管理组或默认管理组的子级,并且创建者分配有“所有者”角色。This new management group becomes a child of the Root Management Group or the default management group and the creator is given an "Owner" role assignment. 管理组服务支持此功能,因此不需要在根级别分配角色。Management group service allows this ability so that role assignments aren't needed at the root level. 创建根管理组时,用户没有访问权限。No users have access to the Root Management Group when it's created. 为避免在查找 Azure AD 全局管理员以开始使用管理组方面遇到阻碍,我们允许在根级别创建初始管理组。To avoid the hurdle of finding the Azure AD Global Admins to start using management groups, we allow the creation of the initial management groups at the root level.

在 Azure PowerShell 中创建Create in Azure PowerShell

在 PowerShell 中,使用 New-AzManagementGroup cmdlet 创建新的管理组。For PowerShell, use the New-AzManagementGroup cmdlet to create a new management group. 在本示例中,管理组 GroupName 为 Contoso。In this example, the management group GroupName is Contoso.

New-AzManagementGroup -GroupName 'Contoso'

GroupName 是要创建的唯一标识符。The GroupName is a unique identifier being created. 此 ID 由其他命令用来引用此组,并且以后无法更改。This ID is used by other commands to reference this group and it can't be changed later.

如果希望管理组在 Azure 门户中显示一个不同的名称,请添加 DisplayName 参数。If you want the management group to show a different name within the Azure portal, add the DisplayName parameter. 例如,若要创建 GroupName 为 Contoso 且显示名称为“Contoso Group”的管理组,请使用以下 cmdlet:For example, to create a management group with the GroupName of Contoso and the display name of "Contoso Group", use the following cmdlet:

New-AzManagementGroup -GroupName 'Contoso' -DisplayName 'Contoso Group'

在上述示例中,新的管理组是在根管理组下创建的。In the preceding examples, the new management group is created under the root management group. 若要指定一个不同的管理组作为父级,请使用 ParentId 参数。To specify a different management group as the parent, use the ParentId parameter.

$parentGroup = Get-AzManagementGroup -GroupName Contoso
New-AzManagementGroup -GroupName 'ContosoSubGroup' -ParentId $parentGroup.id

清理资源Clean up resources

若要删除上面创建的管理组,请使用 Remove-AzManagementGroup cmdlet:To remove the management group created above, use the Remove-AzManagementGroup cmdlet:

Remove-AzManagementGroup -GroupName 'Contoso'

后续步骤Next steps

在本快速入门中,你创建了一个管理组来组织资源层次结构。In this quickstart, you created a management group to organize your resource hierarchy. 管理组可以包含订阅或其他管理组。The management group can hold subscriptions or other management groups.

若要详细了解管理组以及如何管理资源层次结构,请继续学习:To learn more about management groups and how to manage your resource hierarchy, continue to: