Capture an image of an Azure Windows virtual machine created with the classic deployment model.
Azure has two different deployment models for creating and working with resources: Resource Manager and Classic. This article covers using the Classic deployment model. Microsoft recommends that most new deployments use the Resource Manager model. For Resource Manager model information, see Create a copy Windows VM running in Azure.
This article shows you how to capture an Azure virtual machine running Windows so you can use it as an image to create other virtual machines. This image includes the operating system disk and any data disks that are attached to the virtual machine. It doesn't include networking configurations, so you'll need to configure those when you create the other virtual machines that use the image.
Azure stores the image under My Images. This is the same place where any images you've uploaded are stored. For details about images, see About images for virtual machines.
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:
- Create a virtual machine from an image
- How to attach a data disk to a virtual machine
- Make sure the server roles are supported with Sysprep. For more information, see Sysprep Support for Server Roles.
This process deletes the original virtual machine after it's captured.
Prior to caputuring an image of an Azure virtual machine, it is recommended the target virtual machine be backed up. Azure virtual machines can be backed up using Azure Backup. For details, see Back up Azure virtual machines. Other solutions are available from certified partners. To find out what’s currently available, search the Azure Marketplace.
Capture the virtual machine
- In the Azure classic portal, Connect to the virtual machine. For instructions, see How to sign in 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 Azure classic portal to Stopped.
- In the Azure classic portal, click Virtual Machines and 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 you did that.
Click the check mark to capture the image. The new image is now available under Images.
The image is ready to be used to create virtual machines. To do this, you'll create a virtual machine by using the From Gallery menu item and selecting the image you just created. For instructions, see Create a virtual machine from an image.