如何解决如何直接将Azure VM磁盘上传到Blob存储?
我想直接将 azure虚拟机磁盘导出到 azure blob存储吗?我已经检查了互联网,但找不到方法。
我可以将磁盘下载到本地PC,然后上传到Blob存储。但是,这需要很长时间和手动工作。所以我正在检查一种更直接的方法。也许使用 Azure Storage Explorer ?磁盘和Blob存储位于同一资源组和区域中。
因为有vm磁盘的SAS下载链接,所以我可以将我的问题解释为:
是否有一种方法可以通过以下方式将文件直接传输到Blob存储: 网址?
您有什么建议吗?
解决方法
如果您知道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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。