问题
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