【发布时间】:2016-12-21 09:46:27
【问题描述】:
我知道有两种类型的虚拟机镜像,Generalized 和 Specialized。
如果操作系统已通用化/取消配置,则必须关闭虚拟机才能将其捕获为 VM 映像。将 VM 捕获为 VM 映像后,将自动删除该虚拟机。
如果操作系统是专用,则可以在虚拟机运行或关闭时对其进行捕获。捕获的虚拟机保持不变。如果需要应用一致或跨磁盘捕获,我们建议在捕获 VM 映像之前关闭虚拟机。
在这里,我尝试在不关闭 VM 的情况下捕获图像(Specialized)。 我有下面的代码来使用 PowerShell 捕获图像。
Save-AzureRmVMImage -ResourceGroupName $rgame -VMName $vmname -DestinationContainerName $container -VHDNamePrefix $vhdname
但上面的代码会抛出如下错误
Save-AzureRmVMImage : Capture operation cannot be completed because the VM is not generalized.
ErrorCode: OperationNotAllowed
ErrorMessage: Capture operation cannot be completed because the VM is not generalized.
StatusCode: 409
我发现我可以使用 Set-AzureRmVM
将 VM 设置为 GeneralizedSet-AzureRmVM -ResourceGroupName 'CaptureVmImageRG' -Name 'CaptureVmImage' -Generalized
无论如何,我可以将 VM 设置为 Specialized 并捕获图像。有人可以提供一个有效的 Powershell 命令来创建正在运行的 VM 的专用捕获,以用于备份“时间点”目的,或任何其他机制,例如资源浏览器。
提前致谢。
【问题讨论】:
标签: image azure virtual-machine azure-resource-manager azure-powershell