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
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.
NOTE: 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](https://acomdpsstorage.blob.core.windows.net/dpsmedia-prod/azure.microsoft.com/en-us/documentation/articles/virtual-machines-capture-image-windows-server/20150128060354/vmcapturedimageavailable.png)
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.