Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot capture image of Azure VM [closed]

I think the official Azure instructions on how to capture a VM image must be either incorrect or incomplete. I've run a variety of tests myself (detailed below) and more than two dozen people have complained on the page that the instructions don't work and/or damage their VM's. Surely something is missing from the instructions because people must be able to capture images from Azure VM's.

http://www.windowsazure.com/en-us/manage/windows/how-to-guides/capture-an-image/

The instructions on the page are pretty simple:

  • Remote Desktop into your Azure VM
  • Open an administrator command window
  • Run sysprep with the indicated settings (Out-Of-Box-Experience, Generalize, Shutdown)
  • Hit OK
  • Wait for the system to shut the VM down
  • Click capture in the portal.

It sounds simple but the VM never actually shuts down so you can't actually click the capure button. If you manually shutdown the instance, even after waiting many hours, the resulting image fails to work and the original vhd is destroyed in the process.

Can anyone confirm you are able to capture a running Azure instance using either this workflow or some other workflow? If so, can you tell me what you're doing differently from what I'm doing?

Details - The tests I've run are as follows:

TEST 1 - Win2k8 R2 on Small instance

  • Launch a small instance of Win2k8 R2 in the US West region
  • Remote desktop into the image
  • Run sysprep with OOBE,generalize,shutdown
  • Azure dashboard shows all CPU activity completed after 15min of sysprep, device is idle, steady state is 0.41% cpu
  • Wait several hours (>2.5 hours as of this writing on this instance, >12 hours on other tests)
  • Azure VM is still running, capture button for the instance is unavailable in portal

TEST 2 - Win2k8 R2 on Large instance

  • same steps as Test 1 but on Large instance
  • same results except steady state CPU utilization is 0.08% after 15 minutes

TEST 3 - Win2k12 Data Center Edition on small instance

  • same steps as Test 1 but run Win2k12 Data Center
  • same result as Test 1 except steady state CPU utilization is 4.2%

TEST 4 - Win2k8 R2 on Small instance with Windows update

  • same steps as Test 1 but run Windows Update repeatedly until no more updates available before running sysprep
  • same results as Test 1

TEST 5 - Win2k8 R2 on Small instance with Visual Studio 2012 Update 3

  • same steps as Test 1 but install VS2012 Ultimate and VS2012 Update 3 before running sysprep
  • same results as Test 1

TEST 6 - Win2k8 R2 on Large instance with fully configured IIS server

  • provision our standard server configuation (IIS, .NET 4.5) on a large instance
  • run our standard web service tests
  • run sysprep with OOBE,generalize,shutdown
  • wait 4 hours, allowing sysprep to run
  • use portal to shutdown instance
  • use portal to capture instance
  • generated image doesn't work (provisioning machines with it times out after a couple hours)
  • original VHD doesn't work (can't remote desktop into instance created with the VHD)

TEST 7 - Win2k8 R2 on Large instance with fully configured IIS server

  • same as test 6 except wait 12 hours allowing sysprep to run
  • as of this writing (12+ hours) the VM still hasn't shut down
like image 799
Don Alvarez Avatar asked Sep 28 '13 20:09

Don Alvarez


1 Answers

Make one simple change to your workflow: during sysprep, choose to Quit instead of shutdown. This completes the sysprep process but then just exits the sysprep app.

tl;dr: run the following on the command line:

c:\windows\system32\sysprep\sysprep.exe /generalize /oobe /quit

At this point, you can simply select your running VM in the portal and shut it down (which only takes a few moments). You can then view it, which will be shown as stopped (deallocated). At that point, create the image as described in the tutorial you pointed to. You'll give it a name (e.g. "my specialized image"), click the checkbox stating it's been sysprepped, and click Ok. Your image is created, your original vhd is removed (as now you have a generic version of it), the image is registered in your subscription as a choosable image in the gallery (this takes a few minutes), and you're done.

At this point, create a new image from gallery. View MY IMAGES - you'll see your brand new image listed (you may have to wait a minute or so before attempting this - it might not appear immediately in the list).

Now just give it a username and password, and you should be all set.

Note: If you're worried about losing your VM in this step (e.g. something goes wrong), you can always make a copy of your vhd first. You'll need to use PowerShell (or the cross-platform Node-based command line tool), both downloadable from the windowsazure.com downloads page. You can then copy the vhd to a brand new blob, which essentially makes a backup for you. Should something go wrong, you can either use the backed-up image as the basis for a new virtual machine (which won't be sysprepped yet), or make a copy of it (and so on). To do this, you'll need the url to the vhd, which is displayed in the Disks section of the Dashboard page of your running VM.

like image 148
David Makogon Avatar answered Sep 23 '22 06:09

David Makogon