
欢迎关注我们,了解更多Azure技术资讯
在使用中国区 Azure(由世纪互联运营)时,不少用户会有疑问:
和国际版Azure一样,在不需要停止\解除分配 VM的前提下,中国区 Azure 能进行 OS 磁盘交换吗?
毕竟重新创建虚拟机不仅耗时长,还可能涉及数据迁移和业务中断。今天这篇文章,专门针对中国区Azure场景,从兼容性到操作步骤,一次性讲清楚!
中国区Azure支持,但需注意 2个“中国区Azure的专属前提”。
1. 磁盘与虚拟机区域一致。
目标磁盘必须与原磁盘的虚拟机处于同一个区域的Azure数据中心,中国区Azure不支持跨区域磁盘挂载(例如,您无法将中国北部1区域的磁盘挂载到中国东部2区域),且磁盘类型需匹配(如 SSD Premium 与虚拟机系列兼容)。
2. 请确保 VM 大小和存储类型与要附加的磁盘兼容。
例如,如果要使用的原磁盘位于高级存储中,则 目标VM 需要能支持高级存储(如 DS 系列大小)。 这两个磁盘的大小也必须相同。
此外,不支持将未加密的 VM 与加密的 OS 磁盘混合使用。 如果 VM 不使用 Azure 磁盘加密,则要交换的 OS 磁盘也不应使用 Azure 磁盘加密。 如果磁盘使用磁盘加密集,则这两个磁盘应属于同一个磁盘加密集。
Get-AzDisk -ResourceGroupName myResourceGroup| Format-Table -Property Name 步骤2: 使用#Get the VM 获取资源组中的虚拟机。
#Get the VM $vm = Get-AzVM -ResourceGroupName myResourceGroup -Name myVM
步骤3:(选择性)使用#Stop/ deallocate the VM,停止/取消分配名为 myVM 的 VM。
#(Optional) Stop/ deallocate the VMStop-AzVM -ResourceGroupName myResourceGroup -Name $vm.Name -Force步骤4: 使用#Get the new disk that you want to swap in,将名为 newDisk 的磁盘分配为新的OS磁盘。
#Get the new disk that you want to swap in$disk = Get-AzDisk -ResourceGroupName myResourceGroup -Name newDisk步骤5: 使用#Set the VM configuration to point to the new disk,将虚拟机配置指向新磁盘。
#Set the VM configuration to point to the new disk Set-AzVMOSDisk -VM $vm -ManagedDiskId $disk.Id -Name $disk.Name步骤6: 使用#Update the VM with the new OS disk,更新虚拟机以使用新的操作系统磁盘。
#Update the VM with the new OS diskUpdate-AzVM -ResourceGroupName myResourceGroup -VM $vm步骤7: 使用Start the VM来启动指定的虚拟机。
#Start the VM Start-AzVM -Name $vm.Name -ResourceGroupName myResourceGroup
命令行操作链接:使用 PowerShell 更改 Azure VM 使用的 OS 磁盘
更多有关中国区Azure磁盘的的技术文档,请访问以下链接:
Azure 托管磁盘简介:https://docs.azure.cn/zh-cn/virtual-machines/managed-disks-overview


我们的使命
让云计算更聪明
让云服务更高效

