本文介绍了如何使用"Specialized"捕获Azure VM映像使用Power Shell创建VM的类型?或如何创建RM VM的专用映像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道虚拟机映像有两种类型,通用和专用.

I know that there are two types of virtual machine images, Generalized and Specialized.

  1. 如果已通用/取消配置了操作系统,则必须关闭虚拟机才能将其捕获为VM映像.将虚拟机捕获为虚拟机映像后,虚拟机将被自动删除.

  1. If the OS has been generalized/de-provisioned, the virtual machine must be shut down in order to capture it as a VM Image. Once the VM has been captured as a VM Image, the virtual machine will automatically be deleted.

如果操作系统为专业化,则可以在虚拟机运行或关闭时对其进行捕获.捕获的虚拟机保持不变.如果需要应用程序一致性捕获或跨磁盘捕获,我们建议在捕获VM映像之前先关闭虚拟机.

If the OS is specialized, the virtual machine can be captured while it is running or shut down. The captured virtual machine remains untouched. If an application consistent or cross-disk capture is needed, we recommend the virtual machine is shut down prior to capturing the VM Image.

在这里,我试图在不关闭虚拟机( Specialized )的情况下捕获映像.我有以下代码使用PowerShell捕获图像.

Here I am trying to capture the image without shutting down the VM (Specialised).I have the below code to capture the image using PowerShell.

Save-AzureRmVMImage -ResourceGroupName $rgame -VMName $vmname  -DestinationContainerName $container -VHDNamePrefix $vhdname

但是上面的代码抛出如下错误

but the above code throws the error as below

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

Set-AzureRmVM -ResourceGroupName 'CaptureVmImageRG' -Name 'CaptureVmImage' -Generalized

仍然存在,因此我可以将VM设置为 Specialized 并捕获图像.有人可以提供一个有效的Powershell命令来创建正在运行的VM的专业捕获以用于备份时间点"的目的,或其他任何机制,例如资源浏览器.

Is there anyway so that I can set VM to Specialized and capture the image. Can someone please provide a working Powershell command to create a Specialized capture of a running VM for backup 'point in time' purposes, or any other mechanism e.g. resource explorer.

谢谢.

推荐答案

命令Save-AzureRmVMimage和Set-AzureRmVM用于捕获通用图像.在运行两个cmdlet之前,应登录VM并使用Sysprep准备硬盘.

The commands Save-AzureRmVMimage and Set-AzureRmVM are used for captureing Generalized images. Before you run the two cmdlet, you should log on to VM and use Sysprep to prepare the hard disk.

在ARM模式下,对于Specialized图像,我认为您不需要使用cmdlet来捕获图像. 您可以将VHD复制到另一个存储帐户.复制的VHD是特殊图像.您可以使用VHD重新创建一个包含您的数据的新VM.根据我的知识,您最好在VM停止时复制VHD.有关更多信息,请参阅文章

On ARM mode, for Specialized image, I don’t think you need use cmdlet to capture the image. You could copy your VHD to another storage account. The copied VHD is a Specialized image. You could use the VHD to recreate a new VM which has your data.Based on my knowledge, you had better copy the VHD when the VM is stopped. More information please refer to the article

我认为使用Azure恢复服务保管库是更好的解决方案. Azure支持自动备份您的VM,而无需停止您的VM.您很容易恢复虚拟机.有关更多信息,请参阅文章.

I think using Azure recovery services vault is a better solution. Azure supports backup your VM automatically and no need to stop your VMs. It is easy for you to recovery your VMs. More information please refer to the article.

这篇关于如何使用"Specialized"捕获Azure VM映像使用Power Shell创建VM的类型?或如何创建RM VM的专用映像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 18:12