【问题标题】:How to directly upload an azure VM disk to a blob storage?如何将 Azure VM 磁盘直接上传到 Blob 存储?
【发布时间】:2020-12-15 07:44:33
【问题描述】:

我想将 azure vm 磁盘 直接导出到 azure blob 存储?我在网上查过,但我找不到办法。

我可以将磁盘下载到本地 PC,然后上传到 Blob 存储。但这需要很长时间和手动工作。所以我正在检查一种更直接的方式。是否可以使用 Azure 存储资源管理器?磁盘和 Blob 存储位于同一资源组和区域中。

因为有vm盘的SAS下载链接,所以我可以将我的问题解释为:

有没有办法通过使用 网址?

你有什么建议吗?

【问题讨论】:

标签: azure azure-blob-storage disk azure-vm


【解决方案1】:

如果您知道 Azure 磁盘的 SAS 下载链接,我们可以使用 Azure CLI 命令az storage blob copy start 或命令行实用程序AzCopy 将磁盘作为 vhs 文件上传到 Azure blob 存储。

例如

az login

#Provide the name of your resource group where managed disk is created
resourceGroupName=myResourceGroupName

#Provide the managed disk name 
diskName=myDiskName

#Provide Shared Access Signature (SAS) expiry duration in seconds e.g. 3600.
#Know more about SAS here: https://docs.microsoft.com/en-us/azure/storage/storage-dotnet-shared-access-signature-part-1
sasExpiryDuration=3600

#Provide storage account name where you want to copy the underlying VHD file of the managed disk. 
storageAccountName=mystorageaccountname

#Name of the storage container where the downloaded VHD will be stored
storageContainerName=mystoragecontainername

#Provide the key of the storage account where you want to copy the VHD 
storageAccountKey=mystorageaccountkey

#Provide the name of the destination VHD file to which the VHD of the managed disk will be copied.
destinationVHDFileName=myvhdfilename.vhd

#Generate the SAS for the managed disk 
sas=$(az disk grant-access --resource-group $resourceGroupName --name $diskName --duration-in-seconds $sasExpiryDuration --query [accessSas] -o tsv)

#Copy the VHD of the managed disk to the storage account
az storage blob copy start --destination-blob $destinationVHDFileName --destination-container $storageContainerName --account-name $storageAccountName --account-key $storageAccountKey --source-uri $sas

# check copy status
az storage blob show -n $destinationVHDFileName -c $storageContainerName --account-name $storageAccountName --account-key $storageAccountKey

【讨论】:

    猜你喜欢
    • 2020-06-07
    • 2021-08-26
    • 1970-01-01
    • 1970-01-01
    • 2021-01-11
    • 2013-03-18
    • 2020-10-14
    • 2020-01-03
    • 2016-07-24
    相关资源
    最近更新 更多