none
How to Copy All Containers along with Blobs from one Azure storage account to other storage account

    Question

  • Hi

    I have two Azure Storage accounts. On one of the Storage account, there are almost 100 containers and some blobs in those containers. I want to transfer all these containers along with the blobs in it to <g class="gr_ gr_12 gr-alert gr_gramm gr_hide Grammar" data-gr-id="12" id="12">other Storage account</g>.

    I have seen many tools copying the blobs from one container to <g class="gr_ gr_13 gr-alert gr_gramm Punctuation only-del replaceWithoutSep" data-gr-id="13" id="13">other,</g> but didn't come across any that copies the whole containers as well. Please help with this.

    Thanks

    Friday, July 31, 2015 10:25 AM

Answers

  • Hi,

    you can do that using Powershell to list all containers and AzCopy to copy all blobs in a container.

    Follow these steps:

    1) Install AzCopy (http://aka.ms/downloadazcopypr)

    2) Open Powershell and login in your Azure subscription

    3) Run this script putting the right storage account names and making sure that the AzCopy path is C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy\AzCopy.exe (otherwise change it in the script)

    $SourceStorageAccountName = "<SourceStorageAccountName>"
    $DestStorageAccountName = "<DestStorageAccountName>"
    $SourceStorageKey = Get-AzureStorageKey -StorageAccountName $SourceStorageAccountName
    $DestStorageKey = Get-AzureStorageKey -StorageAccountName $DestStorageAccountName
    $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:https://" + $DestStorageAccountName + ".blob.core.windows.net/" + $c.Name + " /SourceKey:" + $SourceStorageKey.Primary + " /DestKey:" + $DestStorageKey.Primary + " /S"
    
    	Invoke-Expression $cmd
    }

    Regards,

    Federico


    Tuesday, August 4, 2015 4:17 PM

All replies

  • Hi,

    Thank you for reaching out to us.
    I am currently researching to gather more information with regards to your request.
    I shall revert back to you with an update at the earliest.
    Sincerely appreciate your patience.

    Regards,
    Shirisha Paderu

    Friday, July 31, 2015 5:29 PM
    Moderator
  • Hi,

    As per my research, it is not possible to copy all the containers at a time from one storage account to another.

    You might have to consider cloud explorer for copying single container for a faster approach.

    Regards,
    Shirisha Paderu


    Saturday, August 1, 2015 4:41 PM
    Moderator
  • Hi,

    you can do that using Powershell to list all containers and AzCopy to copy all blobs in a container.

    Follow these steps:

    1) Install AzCopy (http://aka.ms/downloadazcopypr)

    2) Open Powershell and login in your Azure subscription

    3) Run this script putting the right storage account names and making sure that the AzCopy path is C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy\AzCopy.exe (otherwise change it in the script)

    $SourceStorageAccountName = "<SourceStorageAccountName>"
    $DestStorageAccountName = "<DestStorageAccountName>"
    $SourceStorageKey = Get-AzureStorageKey -StorageAccountName $SourceStorageAccountName
    $DestStorageKey = Get-AzureStorageKey -StorageAccountName $DestStorageAccountName
    $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:https://" + $DestStorageAccountName + ".blob.core.windows.net/" + $c.Name + " /SourceKey:" + $SourceStorageKey.Primary + " /DestKey:" + $DestStorageKey.Primary + " /S"
    
    	Invoke-Expression $cmd
    }

    Regards,

    Federico


    Tuesday, August 4, 2015 4:17 PM