There are several ways to download virtual disk files associated with Azure VMs in an Azure subscription. You can...
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
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
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.
Keep your Azure VM IP address
Migrate Azure VMs to Hyper-V
Dig Deeper on Cloud computing architecture
Related Q&A from Nirmal Sharma
To execute custom scripts for Azure Windows and Linux VMs to support post-deployment configurations, you'll have to download the Azure Custom Script ...continue reading
Not only can you create Port ACL rules in Hyper-V using PowerShell commands, you can also remove rules associated with a VM and query rules ...continue reading
Prepare Hyper-V to use the VLAN domain concept by configuring Hyper-V virtual switches and assigning VLAN IDs to VMs using either PowerShell cmdlets ...continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.