Sunday, January 11, 2015

How to Capture a Windows Virtual Machine to Use as a Template

This article shows you how to capture an Azure virtual machine running Windows so you can use it like a template to create other virtual machines. This template includes the OS disk and any data disks attached the virtual machine. It doesn't include networking configuration, so you'll need to configure that when you create the other virtual machines that use the template.

Azure treats this template as an image and stores it under My Images. This is also where any images you've uploaded are stored. For more information about images, see About Virtual Machine Images in Azure.

Before You Begin

These steps assume that you've already created an Azure virtual machine and configured the operating system, including attaching any data disks. If you haven't done this yet, see these instructions:

Capture the Virtual Machine

  1. Connect to the virtual machine by clicking Connect on the command bar. For details, see How to Log on to a Virtual Machine Running Windows Server.
  2. Open a Command Prompt window as an administrator.
  3. Change the directory to %windir%\system32\sysprep, and then run sysprep.exe.
  4. The System Preparation Tool dialog box appears. Do the following:
    • In System Cleanup Action, select Enter System Out-of-Box Experience (OOBE) and make sure that Generalize is checked. For more information about using Sysprep, see How to Use Sysprep: An Introduction.
    • In Shutdown Options, select Shutdown.
    • Click OK.
    Run Sysprep
  5. Sysprep shuts down the virtual machine, which changes the status of the virtual machine in the Management Portal to Stopped.
  6. Click Virtual Machines, and then select the virtual machine you want to capture.
  7. On the command bar, click Capture.
    Capture virtual machine
    The Capture the Virtual Machine dialog box appears.
  8. In Image Name, type a name for the new image.
  9. Before you add a Windows Server image to your set of custom images, it must be generalized by running Sysprep as instructed in the previous steps. Click I have run Sysprep on the virtual machine to indicate that you have done this.
  10. Click the check mark to capture the image. When you capture an image of a generalized virtual machine, the virtual machine is deleted.
    The new image is now available under Images.
    Image capture successful

Next Steps

The image is ready to be used as a template to create virtual machines. To do this, you'll create a custom virtual machine by using the From Gallery method and select the image you just created. For instructions, see How to Create a Custom Virtual Machine.

No comments:

Post a Comment