How to create an image of Linux VM in Azure?

Capture a VM in the portal:

Note:  Don't capture image if server is running on production or running and you can't bear its loss. Since capturing image will destroy the current server and you will not be able to run again. You will have to create a new Vm from the captured image only. There is another way to clone the VM which is snapshot, refer to this article How to create a Snapshot in Azure?

We capture image when we create a new server and have installed all dependencies. Now capture an image from this newly created server so you can create other servers quickly in future using the image to save time. After capturing the image of newly created server you can delete it and start creating a server using that image. Follow below steps to capture an image from Azure portal:

  • Go to the Azure portal, then search for and select Virtual machines.
  • Select your VM from the list.
  • On the page for the VM, on the upper menu, select Capture.
  • The Create an image page appears.
  • For Resource group, either select Create new and enter a name, or select a resource group to use from the drop-down list. If you want to use an existing gallery, select the resource group for the gallery you want to use.
  • To create the image in a gallery, select Yes, share it to a gallery as an image version.
  • To only create a managed image, select No, capture only a managed image. The VM must have been generalized to create a managed image. The only other required information is a name for the image.
  • If you want to delete the source VM after the image has been created, select Automatically delete this virtual machine after creating the image. This is not recommended.
  • For Gallery details, select the gallery or create a new gallery by selecting Create new.
  • In Operating system state select generalized or specialized. For more information, see Generalized and specialized images.
  • Select an image definition or select create new and provide a name and information for a new Image definition.
  • Enter an image version number. If this is the first version of this image, type 1.0.0.
  • If you want this version to be included when you specify latest for the image version, then leave Exclude from latest unchecked.
  • Select an End of life date. This date can be used to track when older images need to be retired.
  • Under Replication, select a default replica count and then select any additional regions where you would like your image replicated.
  • When you are done, select Review + create.
  • After validation passes, select Create to create the image.

There are some other ways also to capture image and you can refer below: