针对虚拟机的移动指南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 created from Marketplace resources with plans attached can't be moved across subscriptions. 在当前订阅中取消预配虚拟机,并在新的订阅中重新部署虚拟机。De-provision the virtual machine in the current subscription, and deploy again in the new subscription.
  • 如果没有移动虚拟网络中的所有资源,则无法将现有虚拟网络中的虚拟机移到新订阅。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 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 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 retain 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