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. Learn how to perform these steps using the Resource Manager model.
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.
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:
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.
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.