How to copy all containers along with blocks from one Azure storage account to another storage account

I have two Azure Storage accounts. On one of the storage accounts, these containers contain almost 100 containers and some drops. I want to transfer all these containers along with the drops into it to another storage account.

I saw a lot of tools copying drops from one container to another, but did not come across the fact that it copies all containers. Please help with this.

thanks

+5
source share
3 answers

A bit late, but this PowerShell script will do it ...

#Server side storage copy $SourceStorageAccount = "sourceAccountName" $SourceStorageKey = "sourceAccountAPIKey" $DestStorageAccount = "destinationAccountName" $DestStorageKey = "destinationAccountAPIKey" $SourceStorageContext = New-AzureStorageContext -StorageAccountName $SourceStorageAccount -StorageAccountKey $SourceStorageKey $DestStorageContext = New-AzureStorageContext -StorageAccountName $DestStorageAccount -StorageAccountKey $DestStorageKey $Containers = Get-AzureStorageContainer -Context $SourceStorageContext foreach($Container in $Containers) { $ContainerName = $Container.Name if (!((Get-AzureStorageContainer -Context $DestStorageContext) | Where-Object { $_.Name -eq $ContainerName })) { Write-Output "Creating new container $ContainerName" New-AzureStorageContainer -Name $ContainerName -Permission Off -Context $DestStorageContext -ErrorAction Stop } $Blobs = Get-AzureStorageBlob -Context $SourceStorageContext -Container $ContainerName $BlobCpyAry = @() #Create array of objects #Do the copy of everything foreach ($Blob in $Blobs) { $BlobName = $Blob.Name Write-Output "Copying $BlobName from $ContainerName" $BlobCopy = Start-CopyAzureStorageBlob -Context $SourceStorageContext -SrcContainer $ContainerName -SrcBlob $BlobName -DestContext $DestStorageContext -DestContainer $ContainerName -DestBlob $BlobName $BlobCpyAry += $BlobCopy } #Check Status foreach ($BlobCopy in $BlobCpyAry) { #Could ignore all rest and just run $BlobCopy | Get-AzureStorageBlobCopyState but I prefer output with % copied $CopyState = $BlobCopy | Get-AzureStorageBlobCopyState $Message = $CopyState.Source.AbsolutePath + " " + $CopyState.Status + " {0:N2}%" -f (($CopyState.BytesCopied/$CopyState.TotalBytes)*100) Write-Output $Message } } 

Some credits for the script fall into this blog post ...

http://windowsitpro.com/azure/copy-content-one-azure-storage-account-another

... I fixed his code by deleting the unpleasant long dashes , and added code to iterate over the containers, rather than specifying them manually.

+4
source

I highly recommend you take a look at Azure Storage Explorer https://azure.microsoft.com/en-us/features/storage-explorer/ . It is much easier than astoscopy, and you can even copy and paste between containers.

0
source

Do you see this tool ?: https://azure.microsoft.com/en-us/documentation/articles/storage-use-azcopy/ , it can copy all drops from one container to another.

Although, when I needed to move content between accounts, I ended up downloading all the content to a virtual machine and then uploading it back to a new account.

-1
source

All Articles