//
you're reading...
Azure

Azure: Upload and Download VHDs

With Microsoft Azure Powershell you have the ability to upload and download VHD files between on premise and Azure. Please note that at the time of writing, only the VHD format is supported. First you need to ensure you have Azure Powershell installed, there is a great guide you can follow here

After you’re connected to your subscription, the following Powershell scripts will allow uploading and downloading of VHD’s


Upload VHD

PS C:\>$sourcevhd = “C:\temp\Data.vhd”
PS C:\>$destinationvhd = “https://portalvhdswk8xfas45da.blob.core.windows.net/vhds/Data.vhd”
PS C:\>Add-AzureVhd -LocalFilePath $sourcevhd -Destination $destinationvhd -NumberOfUploaderThreads 5

To get your storage account URL to provide for the destination VHD, log into the management portal, click Storage in the left menu, click on your storage account name, click Containers and then copy the appropriate URL for where you would like to copy the VHD


Register the uploaded VHD

Before you can use the disk, you need to register it in Azure. Which command you run depends on the type of disk.

For Data VHD’s run the below

PS C:\>Add-AzureDisk -DiskName ‘data’ -MediaLocation $destinationvhd -Label ‘data’

Attaching this to a VM in Azure is simple, in the management portal go to Virtual Machines > select the VM to attach to (dont click on the VM name, just select it) > click Attach in the bottom ribbon and attach your disk from there

And for Operating system VHD’s run

PS C:\>Add-AzureDisk -DiskName ‘osdisk’ -MediaLocation $destinationvhd -Label ‘osdisk’ -OS Windows or Linux

To use this OS disk for a new VM, go to the management portal > click Virtual Machines > New > From Gallery and select My Disks


Download VHD

PS C:\>Save-AzureVhd -Source $sourcevhd -LocalFilePath $destinationvhd -NumberOfThreads 5

Discussion

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: