DEV Community

Cover image for How to Capture the Image of a Virtual Machine
Yemisi Oyesainu
Yemisi Oyesainu

Posted on

How to Capture the Image of a Virtual Machine

Hi! I'm here again with some little tips on capturing the Image of a virtual machine. You may wonder, why do I need to do this? Well, it is a good idea to have something you can refer to or make use of in future in case you need to know something about your VM or use your virtual machine again from its fresh state it was when you created and deployed it.

More importantly, when you created an image of a virtual machine, it can be used to create multiple VMs.
In Azure, when the image of a virtual machine is captured, the virtual machine will be temporarily stopped. This to achieve consistency of the data and prevent encountering any problem while creating the image. This is crucial because capturing an image requires a point-in-time snapshot of the virtual machine's disk.

Azure Compute Gallery is an Azure service used for storing images of VMs captured. From the gallery you can share your images and you can replicate them to multiple regions.
Yes, that's the gist.

In my earlier post, Adding Data Disk to a Virtual Machine I created a virtual machine, connected to it, installed a web server role and added a data disk. You can click on the link to see how this was done.

Now let's go through some simple steps to capture the image of a virtual machine. I want to capture the image of the Virtual machine Abiksvm created in the post referred to above.

Step 1
Go to Azure Portal and click on the virtual machine to be captured

Image description

Ascertain the Status of the virtual machine that it is running

Image description

Step 2
Go back to the Azure portal home page and select Azure Compute Gallery

Image description

Click on 'Create'

Image description

I will complete the Project details and Instance details as follows:
Subscription: Azure Pass Sponsorship
Resource group: UniRg
Gallery name: Abiksgallery
Region: East US

Image description

Click on Review and Create

Image description

Click on Create

Image description

Image description

Go to Resource

Image description

The Compute Gallery for storing the VM image we want to capture has been created.

Step 3
Lets go back to the virtual machine we want to capture
Click on Capture

Image description

Image description

Select the Compute Gallery already created, Abiksgallery
And name the VM Image definition. I will name is Abiksimage

Image description

Input the Version number 0.0.1

Image description
The Default replica count is 2.I will leave it at 2.You can input any number you desired.
I will select the two regions where I want to replicate the image captured: West US 2 and UK South

Image description
Click on Review and Create

Image description
Click on Create

Image description

When you click on 'Create', the VM has to be stopped before the snapshot will be taken as seen in the picture above.

Then, the Virtual machine will also be generalised. Generalizing is a process that removes machine and user specific information from the VM. This also has to take place before the image of the VM is taken.

Image description

Image description

When the deployment is complete, that means that the image has been taken. Lets click on Go to Resource and see for ourselves.

Image description

Also, go to the Portal's home page and Click on the gallery, Abiksgallery

Image description

Viola! The image has been successfully captured and stored in the gallery.

Simple. Not so?

What is your view about this? Please leave your comments below

Top comments (0)