使用Get-StorageBlobContent将blob降级到本地目录的问题

时间:2018-07-24 02:37:31

标签: powershell azure azure-storage azure-storage-blobs

我正在尝试使用Get-StorageBlobContent将Blob下载到本地目录。但是,当我指定Blob的容器目录时,出现错误。我的代码如下所示:

$ctx = New-AzureStorageContext $StorageAccountName -StorageAccountKey $StorageAccountKey
$BlobName = "blob123.vhd"
$LocalTargetDirectory = "D:\vhds"
$ContainerName = transfer/2018/vhds
$Get-AzureStorageBlobContent -Blob $BlobName -Container $ContainerName -Destination $LocalTargetDirectory -Context $ctx

它抱怨我指定的容器名称无效:

Container name 'transfer/2018/vhds' is invalid. Valid names start and end with a lower case letter or a number and has in between a lower case letter, number or dash with no consecutive

然后我的问题是,如果我要复制的Blob在存储帐户的文件夹中,如何正确给出其位置?

任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:2)

尝试以下操作:

$ctx = New-AzureStorageContext $StorageAccountName -StorageAccountKey $StorageAccountKey
$BlobName = "2018/vhds/blob123.vhd"
$LocalTargetDirectory = "D:\vhds"
$ContainerName = "transfer"
$Get-AzureStorageBlobContent -Blob $BlobName -Container $ContainerName -Destination $LocalTargetDirectory -Context $ctx

我假设您的Blob容器名称为transfer,并且blob123.vhd出现在2018/vhds文件夹中。