
close
close
In this post, I will show you how you can use the snapshot feature of managed disks to create an exact copy (including identity and SID) of a virtual machine.
This technique should only be used for lab and troubleshooting purposes. The official creation/deployment methods of Azure should be used for production deployments from a generalized image.
This technique is based on the snapshot feature of managed disks. If you are using un-managed disks (VHD files in storage accounts) then check out what managed disks offer and how to convert un-managed disks into managed disks.
advertisment
The method I am using does the following:
Managed disk snapshots are done on a per disk basis. To create a consistent image of the original virtual machine, you must shut it down first (via Azure, not the guest OS). Once the virtual machine is shut down (deallocated), you can create a snapshot of each disk, one at a time.
Identify each of the disks of the virtual machine. Then open each disk and click Create Snapshot.
Creating a Snapshot of the Virtual Machine’s OS Disk [Image Credit: Aidan Finn]
Configuring the Snapshot of the Virtual Machine’s OS Disk [Image Credit: Aidan Finn]
You can generate newly managed disks from the snapshots that were just created. Create an OS disk from the OS disk snapshot and create a data disk from each data disk snapshot. To do this, click Create A Resource in the Azure Portal and search for and select Managed Disks.
Name the managed disk. Once again, use a name that reminds you to attach the disk back to the same slot it was connected to in the original machine. Be sure to pick the correct resource group (it’s hard to move a managed disk), and pick the disk type (Premium SSD, Standard HDD, etc). When it comes to source type, select Snapshot and pick the appropriate disk.
In my example, I’m creating a new data disk from the data disk snapshot. Note that you can pick a larger size if you wish. You will need to extend the partition later in the guest OS. Also note that you cannot create a disk smaller than the original disk using this method.
Create a Newly Managed Data Disk from the Data Disk Snapshot [Image Credit: Aidan Finn]
The Snapshots, the Original Disks, and the New Disks [Image Credit: Aidan Finn]
Now you have enough to build the new machine. Open the new OS disk and click + Create VM. This will open the regular Create Virtual Machine blade. Many of the options will be greyed out because they are pre-configured in the existing disk. Finish the wizard and wait for the virtual machine to be deployed.
advertisment
You can add each of the data disks to the virtual machine. Be sure that each data disk is attached to the same LUN as it was in the original virtual machine. Also, make sure that you copy the Host Caching configuration from the original virtual machine.
There is a pretty strong chance that some service in the virtual machine has failed because the virtual machine previously booted up without the data disks. To be safe, reboot the virtual machine.
Adding Data Disks to the New Virtual Machine [Image Credit: Aidan Finn]
Log into the virtual machine and ensure that:
If everything is OK, you can delete the snapshots, assuming that you don’t want to create any more test/troubleshooting copies of the virtual machine.
More from Aidan Finn
advertisment
Petri Newsletters
Whether it’s Security or Cloud Computing, we have the know-how for you. Sign up for our newsletters here.
advertisment
More in Microsoft Azure
Microsoft's Azure AD Conditional Access Service Can Now Require Reauthentication
May 13, 2022 | Rabia Noureen
Microsoft Addresses Cross-Tenant Database Vulnerability in Azure PostgreSQL
Apr 29, 2022 | Rabia Noureen
Microsoft Simplifies IT Monitoring with New Azure Managed Grafana Service
Apr 19, 2022 | Rabia Noureen
System Center 2022 is Now Available with New Datacenter Management Capabilities
Apr 4, 2022 | Rabia Noureen
Most popular on petri
Log in to save content to your profile.
Article saved!
Access saved content from your profile page. View Saved
Join The Conversation
Create a free account today to participate in forum conversations, comment on posts and more.
Copyright ©2019 BWW Media Group