如何获取Azure托管磁盘的VHD? [英] How to get the VHD of an Azure managed disk?

查看:140
本文介绍了如何获取Azure托管磁盘的VHD?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了带有托管磁盘的VM.默认情况下,托管磁盘不再存储到Blob存储中.问题是我现在需要osdisk的vhd文件,但是我找不到合适的方法来检索它.

I have created a VM with a managed disk. Managed disks are no longer stored into the blob storage by default. Problem is that I now need the vhd file of the osdisk, but I am unable to find a proper way to retrieve it.

我发现的唯一方法是在azure门户中打开磁盘,然后按导出"以创建指向vhd文件的下载链接.这种方法是不希望的.

The only method I found is to open the disk in the azure portal and press Export to create a download link to the vhd file. This method is undesired.

推荐答案

您可以使用PowerShell将托管磁盘的VHD复制/导出到存储帐户

You can copy/export the VHD of a managed disk to a storage account with PowerShell

#Connect to Azure and set your azure subscription

#Declare Variables
$resourceGroupName = 'xxxxx-rg'
$snapshotName = 'xxxxxx.md'
$resourceGroupNameStorageAccount = 'xxxx-rg'
$storageAccountName = 'xxxx-storage'
$storageContainerName = 'xxxxx'
$destinationVHDFileName = 'xxxxxx.vhd'

#Get the Storage Account Key of the Destination Storage Account
$storageAccountKey = Get-AzStorageAccountKey -resourceGroupName $resourceGroupNameStorageAccount -AccountName $storageAccountName

#Generate the SAS for the snapshot
$sas = Grant-AzSnapshotAccess -ResourceGroupName $resourceGroupName -SnapshotName $snapshotName -DurationInSecond 3600 -Access Read

#Create the context of the destination storage account for the snapshot
$destinationContext = New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey ($storageAccountKey).Value[0]

#Copy the snapshot to the destination Storage Account
Start-AzStorageBlobCopy -AbsoluteUri $sas.AccessSAS -DestContainer $storageContainerName -DestContext $destinationContext -DestBlob $destinationVHDFileName

这篇关于如何获取Azure托管磁盘的VHD?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆