针对虚拟机的移动指南Move guidance for virtual machines

本文介绍当前不支持的方案以及移动使用备份的虚拟机的步骤。This article describes the scenarios that aren't currently supported and the steps to move virtual machines with backup.

不支持的方案Scenarios not supported

以下方案尚不受支持:The following scenarios aren't yet supported:

  • 无法移动具有标准 SKU 负载均衡器或标准 SKU 公共 IP 的虚拟机规模集。Virtual Machine Scale Sets with Standard SKU Load Balancer or Standard SKU Public IP can't be moved.

  • 如果没有移动虚拟网络中的所有资源,则无法将现有虚拟网络中的虚拟机移到新订阅。Virtual machines in an existing virtual network can't be moved to a new subscription when you aren't moving all resources in the virtual network.

  • 无法跨订阅移动基于附加了计划的市场资源创建的虚拟机。Virtual machines created from Marketplace resources with plans attached can't be moved across subscriptions. 有关可能的解决方法,请参阅具有 Azure 市场计划的虚拟机For a potential workaround, see Virtual machines with Marketplace plans.

  • 可用性集中的虚拟机不能单独移动。Virtual machines in an availability set can't be moved individually.

Azure 磁盘加密Azure disk encryption

无法移动与密钥保管库集成的虚拟机以实现适用于 Linux VM 的 Azure 磁盘加密适用于 Windows VM 的 Azure 磁盘加密You can't move a virtual machine that is integrated with a key vault to implement Azure Disk Encryption for Linux VMs or Azure Disk Encryption for Windows VMs. 若要移动 VM,必须禁用加密。To move the VM, you must disable encryption.

az vm encryption disable --resource-group demoRG --name myVm1
Disable-AzVMDiskEncryption -ResourceGroupName demoRG -VMName myVm1

具有 Azure 市场计划的虚拟机Virtual machines with Marketplace plans

无法跨订阅移动基于附加了计划的市场资源创建的虚拟机。Virtual machines created from Marketplace resources with plans attached can't be moved across subscriptions. 若要解决此限制问题,可以取消预配当前订阅中的虚拟机,并在新订阅中再次部署该虚拟机。To work around this limitation, you can de-provision the virtual machine in the current subscription, and deploy it again in the new subscription. 通过以下步骤可在新订阅中重新创建虚拟机。The following steps help you recreate the virtual machine in the new subscription. 但不一定适用于所有方案。However, they might not work for all scenarios. 如果该计划在 Azure 市场中不再可用,这些步骤将不起作用。If the plan is no longer available in the Marketplace, these steps won't work.

  1. 复制有关计划的信息。Copy information about the plan.

  2. 将 OS 磁盘克隆到目标订阅,或在源订阅中删除虚拟机后移动原始磁盘。Either clone the OS disk to the destination subscription, or move the original disk after deleting the virtual machine from source subscription.

  3. 在目标订阅中,接受相关计划的 Azure 市场条款。In the destination subscription, accept the Marketplace terms for your plan. 可以通过运行以下 PowerShell 命令来接受这些条款:You can accept the terms by running the following PowerShell command:

    Get-AzMarketplaceTerms -Publisher {publisher} -Product {product/offer} -Name {name/SKU} | Set-AzMarketplaceTerms -Accept
    

    或可以通过门户使用相关计划创建虚拟机的新实例。Or, you can create a new instance of a virtual machine with the plan through the portal. 在接受新订阅中的条款后可以删除虚拟机。You can delete the virtual machine after accepting the terms in the new subscription.

  4. 在目标订阅中,使用 PowerShell、CLI 或 Azure 资源管理器模板从克隆的 OS 磁盘中重新创建该虚拟机。In the destination subscription, recreate the virtual machine from the cloned OS disk using PowerShell, CLI, or an Azure Resource Manager template. 包含附加到磁盘的市场计划。Include the marketplace plan that's attached to the disk. 有关计划的信息应与在新订阅中购买的计划匹配。The information about the plan should match the plan you purchased in the new subscription.

使用 Azure 备份的虚拟机Virtual machines with Azure Backup

若要移动配置了 Azure 备份的虚拟机,必须从保管库中删除还原点。To move virtual machines configured with Azure Backup, you must delete the restore points from the vault.

如果为虚拟机启用了软删除,则在保留这些还原点的情况下,你将无法移动虚拟机。If soft delete is enabled for your virtual machine, you can't move the virtual machine while those restore points are kept. 禁用软删除,或在删除还原点后等待 14 天。Either disable soft delete or wait 14 days after deleting the restore points.

门户Portal

  1. 暂时停止备份并保留备份数据。Temporarily stop the backup and keep backup data.

  2. 若要移动配置了 Azure 备份的虚拟机,请执行以下步骤:To move virtual machines configured with Azure Backup, do the following steps:

    1. 找到虚拟机的位置。Find the location of your virtual machine.
    2. 找到包含以下命名模式的资源组:AzureBackupRG_<VM location>_1Find a resource group with the following naming pattern: AzureBackupRG_<VM location>_1. 例如,名称的格式为 AzureBackupRG_chinanorth2_1。For example, the name is in the format of AzureBackupRG_chinanorth2_1.
    3. 在 Azure 门户中,查看“显示隐藏的类型”。In the Azure portal, check Show hidden types.
    4. 查找类型为 Microsoft.Compute/restorePointCollections 的资源,其命名模式为 AzureBackup_<VM name>_###########Find the resource with type Microsoft.Compute/restorePointCollections that has the naming pattern AzureBackup_<VM name>_###########.
    5. 删除此资源。Delete this resource. 此操作仅删除即时恢复点,不删除保管库中的备份数据。This operation deletes only the instant recovery points, not the backed-up data in the vault.
    6. 删除操作完成后,可以移动虚拟机。After the delete operation is complete, you can move your virtual machine.
  3. 将 VM 移到目标资源组。Move the VM to the target resource group.

  4. 恢复备份。Resume the backup.

PowerShellPowerShell

  1. 找到虚拟机的位置。Find the location of your virtual machine.

  2. 找到采用以下命名模式的资源组:AzureBackupRG_<VM location>_1Find a resource group with the naming pattern - AzureBackupRG_<VM location>_1. 例如,名称可以为 AzureBackupRG_chinanorth2_1For example, the name might be AzureBackupRG_chinanorth2_1.

  3. 如果只移动一个虚拟机,请获取该虚拟机的还原点集合。If you're moving only one virtual machine, get the restore point collection for that virtual machine.

    $restorePointCollection = Get-AzResource -ResourceGroupName AzureBackupRG_<VM location>_1 -name AzureBackup_<VM name>* -ResourceType Microsoft.Compute/restorePointCollections
    

    删除此资源。Delete this resource. 此操作仅删除即时恢复点,不删除保管库中的备份数据。This operation deletes only the instant recovery points, not the backed-up data in the vault.

    Remove-AzResource -ResourceId $restorePointCollection.ResourceId -Force
    
  4. 如果要在此位置将所有虚拟机与备份一起移动,请获取这些虚拟机的还原点集合。If you're moving all the virtual machines with back ups in this location, get the restore point collections for those virtual machines.

    $restorePointCollection = Get-AzResource -ResourceGroupName AzureBackupRG_<VM location>_1 -ResourceType Microsoft.Compute/restorePointCollections
    

    删除每个资源。Delete each resource. 此操作仅删除即时恢复点,不删除保管库中的备份数据。This operation deletes only the instant recovery points, not the backed-up data in the vault.

    foreach ($restorePoint in $restorePointCollection)
    {
     Remove-AzResource -ResourceId $restorePoint.ResourceId -Force
    }
    

Azure CLIAzure CLI

  1. 找到虚拟机的位置。Find the location of your virtual machine.

  2. 找到采用以下命名模式的资源组:AzureBackupRG_<VM location>_1Find a resource group with the naming pattern - AzureBackupRG_<VM location>_1. 例如,名称可以为 AzureBackupRG_chinanorth2_1For example, the name might be AzureBackupRG_chinanorth2_1.

  3. 如果只移动一个虚拟机,请获取该虚拟机的还原点集合。If you're moving only one virtual machine, get the restore point collection for that virtual machine.

    RESTOREPOINTCOL=$(az resource list -g AzureBackupRG_<VM location>_1 --resource-type Microsoft.Compute/restorePointCollections --query "[?starts_with(name, 'AzureBackup_<VM name>')].id" --output tsv)
    

    删除此资源。Delete this resource. 此操作仅删除即时恢复点,不删除保管库中的备份数据。This operation deletes only the instant recovery points, not the backed-up data in the vault.

    az resource delete --ids $RESTOREPOINTCOL
    
  4. 如果要在此位置将所有虚拟机与备份一起移动,请获取这些虚拟机的还原点集合。If you're moving all the virtual machines with back ups in this location, get the restore point collections for those virtual machines.

    RESTOREPOINTCOL=$(az resource list -g AzureBackupRG_<VM location>_1 --resource-type Microsoft.Compute/restorePointCollections)
    

    删除每个资源。Delete each resource. 此操作仅删除即时恢复点,不删除保管库中的备份数据。This operation deletes only the instant recovery points, not the backed-up data in the vault.

    az resource delete --ids $RESTOREPOINTCOL
    

后续步骤Next steps