Search code examples
azureazure-storageazcopy

Using AZCopy to download blobs from all containers at one time


I need to copy all containers and blobs from an Azure storage account. I've figured out how to download one container at a time, but this is quite tedious. I would like to download all of them at one time.

Anyone out there have information on this?

Thanks,

James


Solution

  • As far as I know, we couldn't use azcopy to copy all the container's file to local at one time.

    As you say, we could download one container to local at one time.

    Here is a work around:

    We could firstly list all the container by using command-line tool(e.g powershell)(Get-AzureStorageContainer), then use foreach to download the file to local.

    The powershell script like this:

    $SourceStorageAccountName = "<SourceStorageAccountName>"
    $SourceStorageKey = Get-AzureStorageKey -StorageAccountName $SourceStorageAccountName
    $StorageContext = New-AzureStorageContext -StorageAccountName $SourceStorageKey.StorageAccountName -StorageAccountKey $SourceStorageKey.Primary
    $containers = Get-AzureStorageContainer -Context $StorageContext
    
    foreach ($c in $containers) {
        "Transfer container " + $c.Name
        $cmd = "C:\'Program Files (x86)'\'Microsoft SDKs'\Azure\AzCopy\AzCopy.exe /Source:" + $c.CloudBlobContainer.Uri.AbsoluteUri + " /Dest: +"youfile path"
    
        Invoke-Expression $cmd
    }