Nani
Nani

Reputation: 153

Blobs downloading from azure blob container's folder

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.

Upvotes: 1

Views: 14769

Answers (2)

Jason Ye
Jason Ye

Reputation: 13974

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:

enter image description here

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

Upvotes: 4

Zhaoxing Lu
Zhaoxing Lu

Reputation: 6467

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

Upvotes: 3

Related Questions