Download Azure VHD to local use powershell

 ̄綄美尐妖づ 提交于 2019-12-24 12:18:11

问题


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


回答1:


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.




回答2:


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.




回答3:


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.




回答4:


Try this.

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



来源:https://stackoverflow.com/questions/46114240/download-azure-vhd-to-local-use-powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!