First of all, why would you want to copy Virtual Hard Drive (VHD) or a blob from a Windows Azure subscription to another? It could be for: doing backups, because your Windows Azure trial is ending, to get a copy of a client’s VM to investigate a problem. So, when one of my client asked me if it was possible to do it, my answer was: “Yes it is, using command line tools”. But since he was looking for a simple solution, I wrote him a little script that I will share here so everyone can enjoy it.
Get Started
To do the copy, you only need to do one PowerShell command. But, in order to execute this command, you need to have Windows Azure command-line tool already installed. At the end of this post, the script to install the Windows Azure command-line tool will be provided.The command
Having installed the required tool, you can execute this one line of code from the Windows Azure command-line:azure vm disk upload <source-path> <target-blob-url> <target-storage-account-key>
Get the source
In this command, you must replace <source-path> by the url of the VHD or blob that you want to copy from.You can get this url through the Windows Azure Portal, using your account where you want to copy from.
- On the left side of the screen click on the Storage icon.
- Then click on the storage name.
- From the top of the screen click on Containers
- And when the container list appears click on the name of the container to get the details view.



Get the destination


Then specify the access propriety to Public Container.
Get the key

Install the Windows Azure command-line tool

@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('http://bit.ly/psChocInstall'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin @powershell "cinst nodejs.install" && SET PATH=%PATH%;%ProgramFiles(x86)%\nodejs @powershell -ExecutionPolicy unrestricted "npm install azure -g" && SET PATH=%PATH%;%USERPROFILE%\AppData\Roaming\npm\ @powershell azure pause
where is the actual command?
ReplyDeleteAbove section "The Command" does not provide actual command but merely shows an empty space:
"The command
Having installed the required tool, you can execute this one line of code from the Windows Azure command-line:
"
Hi,
ReplyDeleteSorry to read about that, the command is there... What browser are you using? I will try to fix that.
I a mean time, here is the command:
azure vm disk upload < source-path> < target-blob-url> < target-storage-account-key>
Regards
My source subscription is disabled, Is there any way to get backup or migrate from that disabled subscription?
ReplyDeleteYou don`t have Read only access?
ReplyDeleteIf not, then you must reactivate the subscription to get access to your data.
Thanks for this article, Frank. Using the CLI to copy blobs between subscriptions was what I was looking for and your commands work perfectly. Right now it is copying my vhd. But I have a question though. I would suppose that the copy works on the cloud and not via my machine. Is that right? I ask this as it is going very slow.
ReplyDeleteThanks again for a concise yet precise blog which would help people like me finish their task without having to look anywhere else.
Shantanu