从Azure Blob容器的文件夹下载Blob [英] Blobs downloading from azure blob container's folder
问题描述
当我从Azure下载blob时:
When I am downloading blobs from Azure:
$BlobName = "20171019/fac/file.jpg"
Get-AzureStorageBlob -Container $ContainerName -Blob $BlobName
通过使用以上命令,我仅获得单个文件.
By using above command I am getting only single file.
Get-AzureStorageBlob -Container $ContainerName
通过这种方式,我可以从容器中获取所有斑点.
By using this I am getting all blobs from container.
20171019
是容器中的文件夹名称,然后是子文件夹 fac
.
20171019
is folder name in container,
then sub folder fac
.
我的要求是从 Fac
文件夹中下载所有blob.
My requirement is to download all blobs from Fac
folder.
推荐答案
我们应该使用此命令 Get-AzureStorageBlobContent
下载Azure存储Blob.
We should use this command Get-AzureStorageBlobContent
to download Azure storage blobs.
如果要下载该容器中的所有Blob,我们可以使用 foreach
进行操作,如下所示:
If you want to download all blobs in that container, we can use foreach
to do it, like this:
$RGName = "your resource group name"
$SAName = "your storage account name"
$ConName = "your container name"
$key = "your storage account key"
$Ctx = New-AzureStorageContext -StorageAccountName $SAName -StorageAccountKey $Key
$List = Get-AzureStorageBlob -prefix "20171019/fac/" -Container $ConName -Context $Ctx
$List = $List.name
foreach ( $l in $list ){
Get-AzureStorageBlobContent -Blob $l -Container $conname -Context $ctx
}
这是结果:
谢谢Gaurav的建议,我在脚本中添加了 -perfix
.
Thank you for Gaurav's suggestion, I add -perfix
to that script.
这篇关于从Azure Blob容器的文件夹下载Blob的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!