Blobs downloading from azure blob container's folder

纵然是瞬间 提交于 2021-02-07 10:25:52

问题


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 is folder name in container, then sub folder fac.

My requirement is to download all blobs from Fac folder.


回答1:


We should use this command Get-AzureStorageBlobContent to download Azure storage blobs.

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
}

Here is the result:

Thank you for Gaurav's suggestion, I add -perfix to that script.




回答2:


Besides Azure PowerShell, you can also try AzCopy, which has even better performance.

AzCopy /Source:https://myaccount.blob.core.windows.net/mycontainer/20171019/fac /Dest:C:\myfolder /SourceKey:key /S


来源:https://stackoverflow.com/questions/47052388/blobs-downloading-from-azure-blob-containers-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!