How to Capture a Windows Virtual Machine to Use as a Template
This article shows you how to capture a Windows virtual machine so you can use it as template to create other virtual machines. This virtual machine 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.
After you capture the virtual machine, it's available under My Images when you create a virtual machine. The image file is stored as a VHD in your storage account. For more information about images, see Manage Disks and Images.
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
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.
Open a Command Prompt window as an administrator.
Change the directory to
%windir%\system32\sysprep, and then run sysprep.exe.
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.
Sysprep shuts down the virtual machine, which changes the status of the virtual machine in the Management Portal to Stopped.
Click Virtual Machines, and then select the virtual machine you want to capture.
On the command bar, click Capture.
The Capture the Virtual Machine dialog box appears.
In Image Name, type a name for the new image.
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.
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.
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.