Copying VHDs (and other blobs) between storage accounts

The Windows Azure cross platform command line tools expose an extremely useful new feature in Windows Azure Storage which is the ability to asynchronously copy blobs into storage accounts. The source blobs do not HAVE to be in a Windows Azure storage account. They could be anywhere that is publicly accessible. For more details on this new feature see Gaurav’s post on new Windows Azure storage features.

In this post I’m going to show how you can use this feature to copy VHDs between storage accounts which is a very commonly requested activity.

To get started you will need to download and configure the command line tools:

http://www.windowsazure.com/en-us/develop/nodejs/how-to-guides/command-line-tools/

Once downloaded and configured the syntax for moving the blobs is simple:

azure vm disk upload <source-path> <target-blob-url> <target-storage-account-key>

The source path could be any publicly available source location such as an http server:

azure vm disk upload http://sourcewebsite.cloudapp.net/copyme.zip http://targetstorageaccount.blob.core.windows.net/testcopy/copyme.zip TARGETSTORAGEACCOUNTKEY

The copy is made by the Windows Azure storage service itself so the bits are never copied to your local machine which makes the transfer MUCH faster than doing this using storage tools.

To copy VHDs you can use the same syntax:

azure vm disk upload http://sourcestorageaccount.blob.core.windows.net/migratedvhds/myvm.vhd http://targetstorageaccount.blob.core.windows.net/migratedvhds/myvm.vhd TARGETSTORAGEACCOUNTKEY

Keep in mind that the source storage container either needs to be marked public or you can also specify the URL with a shared access signature which is the recommended approach for security reasons (put it in quotes). The target storage account doesn’t need the signature because you are required to specify the storage account key.

Before you ask – yes we definitely will have this functionality in the Windows Azure PowerShell cmdlets in the near future.

Thanks!
Michael

6 thoughts on “Copying VHDs (and other blobs) between storage accounts

  1. Your link to the tools goes to a page “Tools for Mac and Linux” is there a separate link for Windows based? Thanks

    • The Windows install directions are buried a bit but they are there:

      Linux and Windows: Install the latest version of Node.js (see Install Node.js via Package Manager), then run the following command:
      npm install azure -g

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s