This article shows you how to capture an Azure virtual machine running Linux 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.
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:
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. Note that the output from
waagent may vary slightly depending on the version of this utility:
$ sudo waagent -deprovision+user
This command will attempt to clean the system and make it suitable for re-provisioning. This operation performs the following tasks:
rootuser's password from /etc/shadow (if Provisioning.DeleteRootPassword is 'y' in the configuration file)
Type y to continue.
Note that you can add the
-force parameter to avoid this confirmation step.
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.
See Also: Azure Linux Agent User Guide