Manage Learn to apply best practices and optimize your operations.

Download Azure VM disks using PowerShell

Use a simple series of PowerShell commands to download an Azure VM's Windows OS disk for backup and restore. You only need to change a variable or two to download another disk.

There are several ways to download virtual disk files associated with Azure VMs in an Azure subscription. You can...

use the Azure portal, Azure PowerShell cmdlets, Azure Storage Explorer and third-party tools that interact with Azure storage accounts. Azure stores VM files on Azure disks. An Azure VM has at least two disks associated with it: a Windows OS disk and a temporary disk. The Windows OS disk is where the Windows OS is installed, whereas the temporary disk is used by Azure for internal and maintenance purposes. You might want to download the Windows OS disk to a local machine for backup and restore purposes. In this article, we'll explain how to download Azure VM disks using PowerShell.

If you want to download Azure VM disks using PowerShell, you'll need to use the Save-AzureRMVHD PowerShell cmdlet. Note that the Azure VM must be stopped before the disk associated with the VM can be downloaded. To begin downloading Azure VM disks using PowerShell, execute the series of PowerShell commands shown below:

  • Step 1: Log in to an Azure account by executing the Login-AzureRMAccount cmdlet, which opens a credential popup. Enter the credential to connect to the Azure subscription.
  • Step 2: Once connected, execute Get-AzureRMSubscription if you have multiple Azure subscriptions, and list the Azure subscription IDs associated with each Azure subscription.
  • Step 3: Select the Azure subscription by executing Select-AzureRMSubscription -SubscriptionID <SubscriptionID here>.
  • Step 4: Next, stop the VM by executing Stop-AzureRMVM –ResourceGroupName <Resource Group Name> -Name <Azure Virtual Machine Name>.
  • Step 5: Once the Azure VM is stopped, use the PowerShell command below to download each Azure VM disk to a local machine in the C:\Temp\AzureDisks folder:

$DiskPath = "http://storageAccountName.blog.core.Windows.Net/vhdstore/OSImageName.VHD"

Save-AzureRMVHD –ResourceGroupName <Azure Virtual Machine Name> -SourceURI $DiskPath –LocalFilePath "C:\Temp\AzureDisks\VMDisk1.VHD"

Download the complete path for Azure VM disks

If you want to download another disk for the same VM, all you need do is change the $DiskPath variable and where the disk file should be stored.

As shown above, Save-AzureRMVHD downloads the disk specified in the -SourceURI parameter and stores the downloaded file in the C:\Temp\AzureDisks folder on the local machine. The $DiskPath variable contains the complete path to the disk. You'll need to retrieve the complete path of each disk you want to download before the last PowerShell command can be successful. To retrieve the virtual hard disk path for a VM, go to the Azure portal, navigate to the Azure storage account and then select the VHD to show the complete Uniform Resource Idenitifier. Here is an example of a complete VHD path: http://storageAccountName.blog.core.Windows.Net/vhdstore/OSImageName.VHD. If you want to download another disk for the same VM, all you need do is change the $DiskPath variable and where the disk file should be stored.

Next Steps

Keep your Azure VM IP address

Use Microsoft Azure VM Scale Sets

Migrate Azure VMs to Hyper-V

This was last published in October 2017

Dig Deeper on Cloud computing architecture



Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Join the conversation

1 comment

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

What are your best practices for backing up Azure VMs?