This is an extension to azure cli that allows copying virtual machine images between regions with just one command.
The extension simplifies the process and also enables you to save time by copying to multiple regions in parallel. This is now becoming a question I am getting a lot from UK Academics who now wish to move existing Azure resources to the UK Azure Data Center
How to use
Step1. You need Azure Command Line Interface Installed
Step 2. Install Azure CLI
Install on macOS
On macOS, you are able to install either with Homebrew or manually.
Install with Homebrew
If you don't have it already, install Homebrew by following the Homebrew installation instructions.
If you have previously installed the CLI manually, follow the manual uninstall instructions.
Update your local Homebrew repositories.
brew install azure-cli
If you previously installed the Azure Cli 1.0 with Homebrew, instead of installing the package you can get CLI 2.0 through the regular Homebrew upgrade process.
Install Azure CLI 2.0 with
curl -L https://aka.ms/InstallAzureCli | bash
You may have to restart your shell for some changes to take effect.
exec -l $SHELL
Run the CLI from the Command prompt with the
Install on Windows
Install with MSI for the Windows command-line
To install the CLI on Windows and use it in the Windows command-line, download and run the Azure CLI Installer (MSI).
Install with apt-get for Bash on Ubuntu on Windows
If you don't have Bash on Windows, install it.
Open the Bash shell.
Modify your sources list.
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ wheezy main" | sudo tee /etc/apt/sources.list.d/azure-cli.list
Run the following sudo commands:
sudo apt-key adv --keyserver packages.microsoft.com --recv-keys 52E16F86FEE04B979B07E28DB02C46DF417A0893 sudo apt-get install apt-transport-https sudo apt-get update && sudo apt-get install azure-cli
Run the CLI from the command prompt with the
Step 3. Install the Extension
First, install the extension:
az extension add --name image-copy-extension
Step4, Run the Extension command
Then, call it as you would any other az command:
az image copy --source-resource-group mySources-rg --source-object-name myImage --target-location uksouth northeurope --target-resource-group "images-repo-rg" --cleanup
One thing you should keep in mind is that we are relying on the source os disk as the actual source for the copy. So, when you "capture" a new image off a vm in Azure, don't delete the os disk if your intention is to copy it to other regions.
Other options and examples of using the extensions can be viewed with the help command:
az image copy --help
This extension is also available at https://github.com/Azure/azure-cli-extensions/tree/master/src/image-copy so if your interested in building out your own extensions.
This post first appeared on MSDN Blogs | Get The Latest Information, Insights, Announcements, And News From Microsoft Experts And Developers In The MSDN Blogs., please read the originial post: here