gpt4 book ai didi

azure - 如何获取 Azure 托管磁盘的 VHD?

转载 作者:行者123 更新时间:2023-12-02 06:11:48 25 4
gpt4 key购买 nike

我已经创建了一个带有托管磁盘的虚拟机。默认情况下,托管磁盘不再存储在 Blob 存储中。问题是我现在需要 osdisk 的 vhd 文件,但我无法找到正确的方法来检索它。

我找到的唯一方法是在 Azure 门户中打开磁盘,然后按“导出”创建 vhd 文件的下载链接。这种方法是不受欢迎的。

最佳答案

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

#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 - 如何获取 Azure 托管磁盘的 VHD?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42388855/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com