azure - 如何将azure VM磁盘直接上传到blob存储?

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

我想将azure vm磁盘直接导出到azure blob存储吗?我在网上查了一下,但没有找到方法。

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

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

Is there a way to transfer a file directly to blob storage by using a url?

你有什么建议吗?

最佳答案

如果您知道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://learn.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

关于azure - 如何将azure VM磁盘直接上传到blob存储?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63598797/

相关文章:

Azure 服务总线队列一次仅接收 450 条消息

azure - 带有快照的 Azure Blob(页和 block )的文件大小是多少?

macos - 如何查找磁盘卷的格式

python - 创建基于磁盘的数据结构

azure - AddAzureKeyVault 在 dotnet core 应用程序启动期间引入延迟,至少 15 秒延迟

azure - 通过 Azure 逻辑应用从 Azure 容器中上次修改的文件夹中获取 Blob 内容

javascript - 如何在 D3.js 中读取 Blob

azure - 不确定该容器是否在 azure storage 中列为 []

android - 如何加密整个磁盘?

azure - Microsoft 授权端点 - 添加 Dynamics 365 Business Central 权限