Copying storage data from one Azure account to another Copying storage data from one Azure account to another azure azure

Copying storage data from one Azure account to another


You can also use AzCopy that is part of the Azure SDK.

Just click the download button for Windows Azure SDK and choose WindowsAzureStorageTools.msi from the list to download AzCopy.

After installing, you'll find AzCopy.exe here: %PROGRAMFILES(X86)%\Microsoft SDKs\Windows Azure\AzCopy

You can get more information on using AzCopy in this blog post: AzCopy – Using Cross Account Copy Blob

As well, you could remote desktop into an instance and use this utility for the transfer.

Update:

You can also copy blob data between storage accounts using Microsoft Azure Storage Explorer as well. Reference link


Since there's no direct way to migrate data from one storage account to another, you'd need to do something like what you were thinking. If this is within the same data center, option #2 is the best bet, and will be the fastest (especially if you use an XL instance, giving you more network bandwidth).

As far as complexity, it's no more difficult to create this code in a worker role than it would be with a local application. Just run this code from your worker role's Run() method.

To make things more robust, you could list the blobs in your containers, then place specific file-move request messages into an Azure queue (and optimize by putting more than one object name per message). Then use a worker role thread to read from the queue and process objects. Even if your role is recycled, at worst you'd reprocess one message. For performance increase, you could then scale to multiple worker role instances. Once the transfer is complete, you simply tear down the deployment.

UPDATE - On June 12, 2012, the Windows Azure Storage API was updated, and now allows cross-account blob copy. See this blog post for all the details.


here is some code that leverages the .NET SDK for Azure available at http://www.windowsazure.com/en-us/develop/net

using System;using System.Collections.Generic;using System.Linq;using System.Text;using Microsoft.WindowsAzure.StorageClient;using System.IO;using System.Net;namespace benjguinAzureStorageTool{    class Program    {        private static Context context = new Context();        static void Main(string[] args)        {            try            {                string usage = string.Format("Possible Usages:\n"                + "benjguinAzureStorageTool CopyContainer account1SourceContainer account2SourceContainer account1Name account1Key account2Name account2Key\n"                );                if (args.Length < 1)                    throw new ApplicationException(usage);                int p = 1;                switch (args[0])                {                    case "CopyContainer":                        if (args.Length != 7) throw new ApplicationException(usage);                        context.Storage1Container = args[p++];                        context.Storage2Container = args[p++];                        context.Storage1Name = args[p++];                        context.Storage1Key = args[p++];                        context.Storage2Name = args[p++];                        context.Storage2Key = args[p++];                        CopyContainer();                        break;                    default:                        throw new ApplicationException(usage);                }                Console.BackgroundColor = ConsoleColor.Black;                Console.ForegroundColor = ConsoleColor.Yellow;                Console.WriteLine("OK");                Console.ResetColor();            }            catch (Exception ex)            {                Console.WriteLine();                Console.BackgroundColor = ConsoleColor.Black;                Console.ForegroundColor = ConsoleColor.Yellow;                Console.WriteLine("Exception: {0}", ex.Message);                Console.ResetColor();                Console.WriteLine("Details: {0}", ex);            }        }        private static void CopyContainer()        {            CloudBlobContainer container1Reference = context.CloudBlobClient1.GetContainerReference(context.Storage1Container);            CloudBlobContainer container2Reference = context.CloudBlobClient2.GetContainerReference(context.Storage2Container);            if (container2Reference.CreateIfNotExist())            {                Console.WriteLine("Created destination container {0}. Permissions will also be copied.", context.Storage2Container);                container2Reference.SetPermissions(container1Reference.GetPermissions());            }            else            {                Console.WriteLine("destination container {0} already exists. Permissions won't be changed.", context.Storage2Container);            }            foreach (var b in container1Reference.ListBlobs(                new BlobRequestOptions(context.DefaultBlobRequestOptions)                { UseFlatBlobListing = true, BlobListingDetails = BlobListingDetails.All }))            {                var sourceBlobReference = context.CloudBlobClient1.GetBlobReference(b.Uri.AbsoluteUri);                var targetBlobReference = container2Reference.GetBlobReference(sourceBlobReference.Name);                Console.WriteLine("Copying {0}\n to\n{1}",                    sourceBlobReference.Uri.AbsoluteUri,                    targetBlobReference.Uri.AbsoluteUri);                using (Stream targetStream = targetBlobReference.OpenWrite(context.DefaultBlobRequestOptions))                {                    sourceBlobReference.DownloadToStream(targetStream, context.DefaultBlobRequestOptions);                }            }        }    }}