1
votes

How can I download azure vhd with powershell to local machine?

I read the document, but I can't find the blob url like "https://XXX.blob.core.windows.net/vhds/XXX.vhd"

Anybody know that?

Thanks

4
Your VM uses managed disk? You could check it on Azure Portal, on your VM resource group, you could find a disk resource. - Shui shengbao
If you use managed disk, you could not see the vhd file in your storage account. Please check my answer. - Shui shengbao

4 Answers

1
votes

According to your description, your VM uses managed disk not unmanaged disk. So, you could not find the VHD file in storage account. More information about managed disk please refer to this link.

If you want to download the VHD in managed disk, you should copy it to a storage account first.

##create $SAS
$sas = Grant-AzureRmDiskAccess -ResourceGroupName shui -DiskName shuitest -DurationInSecond 3600 -Access Read 
$destContext = New-AzureStorageContext –StorageAccountName contosostorageav1 -StorageAccountKey 'YourStorageAccountKey' 
Start-AzureStorageBlobCopy -AbsoluteUri $sas.AccessSAS -DestContainer 'vhds' -DestContext $destContext -DestBlob 'MyDestinationBlobName.vhd'

Then, you could use Save-AzureVhd or Azcopy to download the VHD to your local.

Please refer to the similar question.

1
votes

You can use Save-AzureVhd cmdlet to download the vhd file to local machine.

The Save-AzureVhd cmdlet enables download of .vhd images from a blob where they are stored to a file. It has parameters to configure the download process by specifying the number of downloader threads that are used or overwriting the file which already exists in the specified file path.

Save-AzureVhd does not do any VHD format conversion and the blob is downloaded as it is.

Example PowerShell cmdlets:

Save-AzureVhd -Source "http://YourStorageaccountname.blob.core.windows.net/yourContainerName/win7baseimage.vhd" -LocalFilePath "C:\vhd\Win7Image.vhd"

To get the exact URL, Login to Azure Portal, Select Storage Account and the vhd file, then copy the path.

You can also use Azure Storage Explorer to download the vhd file easily.

0
votes

https://storage-account-name.blob.core.windows.net/container-name/vhd-name.vhd

You can also find the URL in Azure Portal. Open your storage account, go into the container and click the VHD you want. You will see "URL" in "Blob properties" blade.

0
votes

Try this.

Download, install, login and then browse to your container, select your .vhd and click download.