Capturing A Specialized Windows VM And Creating A New VM From Captured Image In Azure

When we create a virtual machine in Azure, there are options available to select the virtual machine images (generalized images) from the gallery, as provided by Microsoft, other third party providers and use the custom images (only available in classic portal now). We can upload the custom images, if we have created the images locally or we can create an image by capturing it from an already created virtual machine in Azure.

Below, are the two options, available for the image capturing:

  • Generalized
  • Specialized

When we capture a VM image as a generalized, it does not contain any user and system specific settings.

It is captured as a plain template and it’s useful to use as a standard template to create other virtual machines for the different users as it doesn’t have user specific details. To capture this kind of image, we need to run a tool on VM known as System Preparation tool (Sysprep) and need to shut down the VM.

When we capture a VM image as a specialized image, it contains the user, system specific data and we don’t need to shut down the VM for the image capturing. However, it is recommended to shut down VM. This kind of capturing is useful to create the restore point of VMS. Thus, when live VM faces any failure, we can create new VM with the previously captured image.

To complete this tutorial, you'll need the following,

  • An active Azure account. (If you don't have an account, you can create a free trial account in just few minutes. For details, see Azure Free Trial.)

Capturing virtual machine image

To capture virtual machine image, follow the steps, given below:

  1. Login to Azure classic portal . In this article, I used classic portal. However, capturing virtual machine image is also possible from the new portal and creating a new virtual machine from the captured image is not yet available in the new portal.

  2. In the portal, click Virtual machines tab, as shown in the image, given below, my subscription already has a virtual machine created and I configured it with my requirements.

    virtual machine

    As you have observed the status of the virtual machine is running, I have not stopped it, as needed, when we have to create the generalized image.

  3. Now, click on Capture button, as shown in the image, given above, at the bottom side. This action will open a Capture the virtual machine popup box for taking an image name and the description, as shown in the image, given below:

    CAPTURE


There is a warning at the top regarding the virtual machine running state, as for Application consistency state, it is recommended to stop the VM. Enter the Image name, description and click the right tick mark button. This action starts the capturing of VM image, as shown in the image, given below:

image

After successfully capturing the image notification, status changes to success, as shown in the image, given below:

status

We can view the newly created virtual machine image by going to Virtual machines tab, followed by Images tab, as shown in the image, given below:

IMAGES

As shown in image, shown above, if you clicked on the captured image; named Captured_Development_VM, it will show the details of the captured image, as shown in the image, given below. You can observe that the captured image is of Windows specialized OS type.

Captured_Development_VM

This captured virtual machine image is a VHD file and stored in the storage account. We can verify it, as shown in the image, given below, by going to Storage->select storage account->Containers-> select VHDS container.

VHD

Creating Virtual machine from captured image

To create the virtual machine from the captured image, follow the steps, given below. This functionality is available in the classic portal right now and not available in the new portal.

  1. Go to Virtual machines tab and click + New button at the left bottom corner, as shown in the image, given below:

    Virtual machines

  2. Select Compute -> Virtual machine -> From Gallery, as shown in the image, given below. To create the virtual machine from custom image, we need to select from gallery option as quick create will not provide the option to select the custom image.

    Virtual machine

  3. In Create a virtual machine Window, select My images and then select the captured image, as shown in the image, given below. When we create the custom image by capturing or uploading from the local, all are stored accessed from My images tab, while creating VM.

     MY IMAGES

  4. Click right arrow button, enter virtual machine name and select tier and virtual machine size, as shown in the image, given below. When we create the virtual machine from the captured image, it does not matter from which tier and of which size we captured image. We can select different tier and size.

    create

  5. Click right arrow button and provide the details, given below:

    • Cloud Service: Need to select Cloud Service, where our virtual machine will reside. If you have already created Cloud Service , you can select it or you can select option to create new one, as I selected.

    • Cloud service DNS name: You can provide the Cloud Service name, if you selected Create a new Cloud Service in step 1. It takes the virtual machine name, which we have provided in step 4 automatically for the Cloud Service name or we can give our preferred unique name, which is available in CLOUDAPP.NET. If given name is available, a green tick mark is shown.

    • Select the subscription in which we want to create this new virtual machine.

    • Select Region or virtual network: We can select the virtual network, if we have to place our virtual machine in Azure provided virtual network for better security and management. For this article, I am selecting the region, in which we have to create the virtual machine.

    • Availability set: Select availability set, if created earlier. Select NONE, if don’t want to place VM within an availability set or create an availability set.

    • Endpoints: Keep the default setting.

      create

  6. Click right arrow button, unselect VM AGENT check box, as we don’t need it  for this, as shown in the image, given below:

    VM AGENT

  7. Click the check mark button. This will start creating a virtual machine from the captured image and shows the status, as shown in the image, given below:

    VM AGENT

After successful creation of the virtual machine, we can connect to the virtual machine, using remote desktop. Remote desktop will take the same login credentials as Development-VM from which, we have captured this specialized image. As you might have observed that we have not provided any login credentials for the remote desktop, while creating the virtual machine. After remote connection, you can verify all the details will be same as Development-VM. You will see all the software installed on Development-VM are available in this new VM. We don’t need to configure it again for the same work. New VM is nothing but a snapshot of Development-VM.

Here, we have seen, how to capture a specialized image for a virtual machine and how to create a new virtual machine from the captured image.