Steps to copy VHDs between azure storage accounts
In this blog, we will show you the steps to copy VHDs between azure storage accounts using command line interface.
- Microsoft Azure Subscription
- VM (or) Physical Machine.
Note: We are using Windows 2016 VM for this demo.
- Open the web browser and access the URL https://azure.microsoft.com/en-us/downloads/
- Scroll down and click on Install Release version click under AzCopy Command-Line Tool for Azure Storage topic.
- Download the MicrosoftAzureStorageTools.msi file on the desktop.
- Double-click on the MicrosoftAzureStorageTools.msi file and it shows the welcome setup screen. Click Next to continue.
- Accept the license agreement and click Next.
- Specify the destination folder for the installation and click Next.
- Click Install to begin the installation.
- Click Finish to complete the installation.
- Log in to the Azure portal using your subscription and click on storage accounts under services list.
- For this demo, we have created 2 storage accounts named grsstorageaccount01 and azstorageaccount03.
- We are copying the data VHD named az-vm-01-datadisk.vhd from grsstorageaccount01 (Source) to azstorageaccount03 (Destination).
FINDING PRIVATE KEYS AND CONTAINER URL
- Login to your Azure portal and click on Storage accounts link from the service list.
- Click on the source storage account named grsstorageaccount01 and select the Access Keys option.
- There are two access keys are available for each storage account. For grsstorageaccount01 storage account, we can use either one key. For this demo, we are using key1.
- The key1 is used for azstorageaccount03 (Destination) account.
- To find the URL of a storage account, click on the storage account and select Blobs services.
- Select the context menu of a container and select container properties.
- You can find the container full URL under URL section.
COPY VHD BETWEEN STORAGE CONTAINERS
- Click on the start menu and select Microsoft Azure Storage command line.
- A new command line windows will open as shown below.
- Use the command azcopy to copy the VHD files between Azure storage accounts. The command syntax is shown below.
Azcopy /source:<The URL of source storage account container> /Dest:<The URL of destination storage account container> /sourcekey:<The source storage account access key> /destkey:<The destination storage account access key> /pattern:<filename>
- The example command to copy the contents is given below.
azcopy /source:https://grsstorageaccount01.blob.core.windows.net/vhds/ /Dest:https://azstorageaccount03.blob.core.windows.net/vhds/ /sourcekey:BtzB79MVlfbQ58yavo5YTk8urfR3DfFw4V/nZ/Q5/5r3z7ArmVlBzadIrNl5ImavBr2gsFZMeQsj7kRDJy490A== /destkey:05MSmqECVwG8WLUZQBJb6h7tEgVhdl9s2lim50YbuiP695hi4T+sJ5EXEdMhIEZ5i2a9mjA5ccsDr4kvOPCJGA== /pattern:az-vm-01-datadisk.vhd
- It will take few minutes based on the VHD size to complete the operation.
- Open the destination BLOB (Binary Large Object) storage account azstorageaccount03 and click on blobs link.
- Click on the vhds container.
- You can able to see the VHD file is available in this container.
Thanks for reading this blog. We hope it was useful for you to know about the Azcopy command and it’s usage.