
close
close
Upcoming FREE Conference on Identity Management and Privileged Access Management
In this article I will show you how to download a virtual machine from Microsoft Azure and get it running on a local or on-premises Hyper-V host/cluster.
It seems like everyone wants to know how to migrate virtual machines into Azure. The answer is to use Azure Site Recovery. I have been working with Azure customers for over two years, and until very recently, no one had asked me, “How do I download a virtual machine from Azure?” I suspected that I knew the answer, so I went online to confirm my suspicion. In this post, I will show you how to get your virtual machine downloaded and running on Hyper-V.
The first thing you need is to understand the anatomy of a (Azure) virtual machine. This process is not going to download a whole virtual machine; instead we will download the disks that make up that virtual machine. The remaining data is metadata, which is pretty meaningless to us. The metadata is a machine specification that we will recreate locally using Hyper-V Manager, Failover Cluster Manager, or System Center Virtual Machine Manager. We will attach the downloaded disks, which contain the OS, programs, settings, and data, to the blank virtual machine. This process takes what we value from the machine and gets it back running where we want it.
Tip: Log into the virtual machine in Azure and note any settings that you need to preserve, such as data drive letters.
The following process requires that the virtual machine is powered down until you are ready to start it up on your Hyper-V host, so make sure you schedule the migration for an agreed maintenance window. You will need to log into the Azure Portal at http://portal.azure.com.
I am going to show you two native ways to complete the process. The first uses the Azure Portal and cannot be automatically scheduled or automated:
Note: I was experiencing a bug when viewing blob properties in the Azure Portal at the time of writing this article and clicking Download didn’t cause a download to occur. You could use the classic management portal at https://manage.windowsazure.com to download disks from Azure V1 or Service Management machines.
Viewing the disks of the Azure virtual machine [Image credit: Aidan Finn]
Login-AzureRmAccount
If you have access to more than one subscription, then list the subscriptions with:
Get-AzureRmSubscription
Copy the SubscriptionID from the required subscription and use it to set your desired subscription:
Select-AzureRmSubscription –SubscriptionId 1ab23456-1234-1a23-abcd-a123abc12345
Shut down the virtual machine:
Stop-AzureRmVM -ResourceGroupName PetriDL -Name PetriDL
Wait for the virtual machine to stop. Then run the following command for each virtual hard disk. Note that I have stored the storage account path of the blob in a variable and am saving the disk to C:\Temp\Azure on my PC:
Save-AzureRmVhd -ResourceGroupName PetriDL -SourceUri $vhdpath -LocalFilePath "C:\Temp\Azure\petridl.vhd"
Downloading Azure virtual machine disk using PowerShell [Image credit: Aidan Finn]
Use your Hyper-V management tool of choice to create a Generation 1 virtual machine without any virtual hard disks on your Hyper-V host or cluster. Try to match the CPU and memory configuration that the Azure virtual machine used. This process will recreate the metadata of the virtual machine for a Hyper-V host/cluster.
Create a new virtual machine with no disks [Image credit: Aidan Finn]
You can use the Edit Disk action in Hyper-V Manager to convert the disk between VHD and VHDX formats.
When the disk(s) is ready, edit the settings of the virtual machine. Attach the disks to the virtual machine as follows:
Here is a list of things you will need to look at or do:
More in Virtualization
Optimizing the VDI User Experience with FSLogix Containers and Application Masking
Mar 8, 2023 | Travis Roberts
Securing Azure Virtual Desktop with Azure Active Directory Conditional Access
Feb 22, 2023 | Shabaz Darr
Microsoft's Azure Virtual Desktop Adds Watermarking Support to Prevent Data Leaks
Feb 17, 2023 | Rabia Noureen
Parallels Desktop is Now Officially Supported for Running Windows 11 on ARM on Apple Silicon Macs
Feb 16, 2023 | Laurent Giret
Most popular on petri