How to Capture a Linux Virtual Machine to Use as a Template
This article shows you how to capture a Linux virtual machine so you can use it as a 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 Linux.
In the SSH window, type the following command and then enter the password for the account that you created on the virtual machine. Note that the output from
waagent may vary slightly depending on the version of this utility:
sudo waagent -deprovision
Type y to continue.
Type Exit to close the SSH client.
In the Management Portal, select the virtual machine, and then click Shut down.
When the virtual machine is stopped, on the command bar, click Capture to open the Capture the Virtual Machine dialog box.
In Image Name, type a name for the new image.
All Linux images must be deprovisioned by running the
waagent command with the
-deprovision option. Click I have run waagent-deprovision on the virtual machine to indicate that the operating system is prepared to be an image.
Click the check mark to capture the image.
The new image is now available under Images. The virtual machine is deleted after the image is captured.
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.