How to Copy Files Between Storage Accounts Using Azcopy in Azure?

Introduction 

Copying files between storage accounts is a common task when working with cloud storage in Azure. Azure provides a powerful command-line tool called AzCopy that simplifies the process of transferring files between different storage accounts. Whether you need to migrate data, back up files, or distribute content, AzCopy is a reliable and efficient solution. 

What is AzCopy?

AzCopy is a command-line utility designed specifically for Azure Storage. It supports copying blobs and files and offers various advanced features such as parallelization, resume support, and synchronization. With AzCopy, you can transfer large amounts of data quickly and securely while maintaining data integrity. 

In this article, we will explore how to use AzCopy to copy files between storage accounts in Azure. 

Step 1. Log in to the Azure portal via https://portal.azure.com/#home

Step 2. We must get the storage account credentials to access the source and destination storage accounts; we need the names of the storage accounts and the SAS tokens for both source and destination accounts. 

Navigate to the relevant Storage Account in your Resource Group, and you can get the Storage Account name from the Overview blade. 

azcopy in Azure

Step 3. Click on “Shared access signature” on the left menu bar to obtain the SAS token. 

azcopy in Azure

Step 4. Select the required services, resource types, permissions, blob index permissions, start and expiry dates, protocols, routing tier, and the signing key. Then click on Generate SAS and connection string to generate the SAS token. 

azcopy in Azure

Step 5. Get the SAS token. 

azcopy in Azure

** Perform steps 2, 3, 4, and 5 for source and destination storage accounts.  

Step 6. Click on the Cloud Shell icon in the top right corner; it will open a terminal, and select Bash from the drop-down menu. 

azcopy in Azure

Step 7. Edit the below command with the relevant values obtained in steps 2, 3, 4, and 5. 

azcopy copy <Source location> <Destination location> --recursive 

Source location - "https://<Source storage account name>.blob.core.windows.net/<Source container name>/<Source file name><Source SAS token>" 

Destination location - "https://<Destination storage account name>.blob.core.windows.net/<Destination container name>/<Destination file name><Target SAS token>" 

AzCopy will initiate the file transfer process, displaying progress updates as it copies the files between the storage accounts. 

azcopy in Azure

You will see the Number of Transfers Completed as “1” after executing the command since we have given only one file to be transferred.  

Step 8. Navigate to the destination storage account; you will be able to see the copied file. 

azcopy in Azure

Summary 

AzCopy is a versatile command-line tool that simplifies the process of copying files between storage accounts in Azure. By following the steps outlined above, you can utilize AzCopy to efficiently transfer data, backup files, or distribute content across different Azure storage accounts.  

Please use the comments section if you have any questions.