3
votes

I am not able to create new Azure VMs using images I have captured through PowerShell.

Here is the situation I am in.

  1. I create 2 Windows VMs "mydevbox1" and "mydevbox2" using the latest image of Windows Server 2012 R2 in Azure gallery
  2. I install necessary software and configure both exactly the same
  3. 3a. I capture the the image of mydevbox1 called mydevbox1-image-PS using the powershell script below.
  4. 3b. I capture the image of mydevbox2 called mydevbox2-image-Manual using the manual/portal process (sysprep -> capture image) (ofcourse I do it from a separate vm).
  5. 4a. When I try to create a new vm using the mydevbox1-image-PS created through powershell, the VM creation process fails (provisioning times out)
  6. 4b. When I try to create a new vm using the mydevbox2-image-Manual created through the manual process, the VM creation is successful.

Please help.

PowerShell Script I am using the capture the image

Save-AzureVMImage –ServiceName $serviceName_toCapture –Name $vmName_toCapture –ImageName $imageName_Captured_Generalized –OSState "Generalized" -ImageLabel $imageLabel_Captured_Generalized -Verbose
1
maybe try to call the cmdlet with -debug to get any additional error information. - Martin Brandl
This should be posted to ServerFault. - David Makogon

1 Answers

0
votes

It fails because you didn't run sysprep before saving the image. The powershell cmdlet won't do it for you. -OSState parameter only saves the reference that the image was generalized or specialized. Details in this blog post:

VM Image PowerShell ‘How To’ Blog Post

http://azure.microsoft.com/blog/2014/05/01/vm-image-powershell-how-to-blog-post/