powershellazure-blob-storageazure-virtual-machinevhd

Download Azure VHD to local use powershell


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


Solution

  • 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.