将维护控制配置中的资源移到另一区域Move resources in a Maintenance Control configuration to another region

按照本文所述将与维护控制配置关联的资源移到另一 Azure 区域。Follow this article to move resources associated with a Maintenance Control configuration to a different Azure region. 出于多种原因,你可能需要移动配置。You might want to move a configuration for a number of reasons. 例如,利用新的区域、部署在特定区域中可用的功能或服务、满足内部策略和治理要求,或者应对容量规划。For example, to take advantage of a new region, to deploy features or services available in a specific region, to meet internal policy and governance requirements, or in response to capacity planning.

使用带自定义维护配置的维护控制,你可以对如何将平台更新应用到 Windows VM、Linux VM 和 Azure 专用主机进行控制。Maintenance control, with customized maintenance configurations, allows you to control how platform updates are applied to Windows and Linux VMs, and to Azure Dedicated Hosts. 跨区域移动维护控制有几种场景:There are a couple of scenarios for moving maintenance control across regions:

  • 若要移动与维护配置关联的资源,但不移动配置本身,请按照本文中的说明操作。To move the resources associated with a maintenance configuration, but not the configuration itself, follow this article.
  • 若要移动维护控制配置,但不移动与配置关联的资源,请按照这些说明操作。To move your maintenance control configuration, but not the resources associated with the configuration, follow these instructions.
  • 若要同时移动维护配置及其关联的资源,请先按照这些说明操作,To move both the maintenance configuration and the resources associated with it, first follow these instructions. 然后再按照本文中的说明操作。Then, follow the instructions in this article.

先决条件Prerequisites

在开始移动与维护控制配置关联的资源之前,必须满足以下先决条件:Before you begin moving the resources associated with a Maintenance Control configuration:

  • 在开始之前,请确保新区域中存在要移动的资源。Make sure that the resources you're moving exist in the new region before you begin.
  • 验证与要移动的 Azure VM 和 Azure 专用主机关联的维护控制配置。Verify the Maintenance Control configurations associated with the Azure VMs and Azure Dedicated Hosts that you want to move. 分别检查每个资源。Check each resource individually. 目前无法检索多个资源的配置。There's currently no way to retrieve configurations for multiple resources.
  • 检索资源的配置时,请遵循以下要求:When retrieving configurations for a resource:
    • 确保使用帐户的订阅 ID,而不是使用 Azure 专用主机 ID。Make sure you use the subscription ID for the account, not an Azure Dedicated Host ID.
    • CLI:--output table 参数仅用于提高可读性,可以删除或更改。CLI: The --output table parameter is used for readability only, and can be deleted or changed.
    • PowerShell:Format-Table Name 参数仅用于提高可读性,可以删除或更改。PowerShell: The Format-Table Name parameter is used for readability only, and can be deleted or changed.
    • 当使用 PowerShell 时,如果尝试列出某个没有任何关联配置的资源的配置,则会出现错误。If you use PowerShell, you get an error if you try to list configurations for a resource that doesn't have any associated configurations. 该错误类似于:“操作失败,状态:‘未找到’。The error will be similar to: "Operation failed with status: 'Not Found'. 详细信息:404 客户端错误:找不到与 url 对应的项”。Details: 404 Client Error: Not Found for url".

准备移动Prepare to move

  1. 在开始之前,请定义以下变量。Before you start, define these variables. 我们为每个变量提供了一个示例。We've provided an example for each.

    变量Variable 详细信息Details 示例Example
    $subId$subId 包含维护配置的订阅的 IDID for subscription containing the maintenance configurations "our-subscription-ID""our-subscription-ID"
    $rsrcGroupName$rsrcGroupName 资源组名称 (Azure VM)Resource group name (Azure VM) "VMResourceGroup""VMResourceGroup"
    $vmName$vmName VM 资源名称VM resource name "myVM""myVM"
    $adhRsrcGroupName$adhRsrcGroupName 资源组(专用主机)Resource group (Dedicated hosts) "HostResourceGroup""HostResourceGroup"
    $adh$adh 专用主机名Dedicated host name "myHost""myHost"
    $adhParentName$adhParentName 父资源名称Parent resource name "HostGroup""HostGroup"
  2. 使用 PowerShell Get-AZConfigurationAssignment 命令检索维护配置:To retrieve the maintenance configurations using the PowerShell Get-AZConfigurationAssignment command:

    • 对于 Azure 专用主机,请运行:For Azure Dedicated Hosts, run:

      Get-AzConfigurationAssignment -ResourceGroupName $adhRsrcGroupName -ResourceName $adh -ResourceType hosts -ProviderName Microsoft.Compute -ResourceParentName $adhParentName -ResourceParentType hostGroups | Format-Table Name
      
    • 对于 Azure VM,请运行:For Azure VMs, run:

      Get-AzConfigurationAssignment -ResourceGroupName $rgName -ResourceName $vmName -ProviderName Microsoft.Compute -ResourceType virtualMachines | Format-Table Name
      
  3. 使用 CLI az maintenance assignment 命令检索维护配置:To retrieve the maintenance configurations using the CLI az maintenance assignment command:

    • 对于 Azure 专用主机,请运行:For Azure Dedicated Hosts:

      az maintenance assignment list --subscription $subId --resource-group $adhRsrcGroupName --resource-name $adh --resource-type hosts --provider-name Microsoft.Compute --resource-parent-name $adhParentName --resource-parent-type hostGroups --query "[].{HostResourceGroup:resourceGroup,ConfigName:name}" --output table
      
    • 对于 Azure VM,请运行:For Azure VMs:

      az maintenance assignment list --subscription $subId --provider-name Microsoft.Compute --resource-group $rsrcGroupName --resource-name $vmName --resource-type virtualMachines --query "[].{HostResourceGroup:resourceGroup, ConfigName:name}" --output table
      

移动Move

  1. 按照这些说明将 Azure VM 移到新区域。Follow these instructions to move the Azure VMs to the new region.
  2. 移动资源后,根据需要将维护配置重新应用于新区域中的资源,具体取决于是否移动了维护配置。After the resources are moved, reapply maintenance configurations to the resources in the new region as appropriate, depending on whether you moved the maintenance configurations. 可以使用 PowerShellCLI 将维护配置应用于资源。You can apply a maintenance configuration to a resource using PowerShell or CLI.

验证移动情况Verify the move

验证新区域中的资源,以及新区域中资源的关联配置。Verify resources in the new region, and verify associated configurations for the resources in the new region.

清理源资源Clean up source resources

移动之后,请考虑在源区域中删除已移动的资源。After the move, consider deleting the moved resources in the source region.

后续步骤Next steps

如果需要移动维护配置,请按照这些说明操作。Follow these instructions if you need to move maintenance configurations.