如何使用 az cli 或 azure 门户将磁盘快照复制到 Azure 容器?

问题描述 投票:0回答:1

我有一个虚拟机磁盘快照,并尝试将其复制到 Azure 容器。

如何使用 Azure 门户手动执行此操作?

我尝试使用 az cli 来执行此操作,如下所示:

$subscriptionId="<subscriptionId>"
    $resourceGroupName=myResourceGroupName
    $snapshotName=mySnapshotName
    $sasExpiryDuration=3600
    $storageAccountName=mystorageaccountname


    $storageContainerName=mystoragecontainername

#Provide the key of the storage account where you want to copy snapshot. 
    $storageAccountKey=mystorageaccountkey

#Provide the name of the VHD file to which snapshot will be copied.
    $destinationVHDFileName=myvhdfilename

   az account set --subscription $subscriptionId

   $sas=$(az snapshot grant-access --resource-group $resourceGroupName --name $snapshotName --duration-in-seconds $sasExpiryDuration --query [accessSas] -o tsv)

az storage blob copy start --destination-blob $destinationVHDFileName --destination-container $storageContainerName --account-name $storageAccountName --account-key $storageAccountKey --source-uri $sas

但复制似乎没有给出错误:

ERROR: unrecognized arguments: https://..... 

我认为这是针对 --source-uri 的?

如何将资源组中的磁盘快照复制到 Azure 容器?

azure powershell
1个回答
0
投票

您遇到的错误似乎是在 CLI 中处理的。

在执行 

--source-uri

命令之前,您可以确保

$sas
变量包含 full URL,包括
https://
前缀。
这里是更新的 

Azure CLI

脚本,用于将 az storage blob copy start 复制到

Snapshot
Azure Container

输出

执行azure cli脚本后,快照已复制到azure存储容器中。

enter image description here

参考:

az存储blob复制开始

© www.soinside.com 2019 - 2024. All rights reserved.