You dont have javascript enabled! Please enable it! How To Copy Files From One Azure Storage Account To Another - CHARBEL NEMNOM - MVP | MCT | CCSP | CISM - Cloud & CyberSecurity

How to Copy Files From One Azure Storage Account to Another

3 Min. Read

In this guide, we will show you how to copy files from one Azure storage account to another storage account.

Introduction

A while ago, we wrote about how to move VHD images from one Azure subscription to another. In this article, we will outline how to copy data from one Azure storage account in one subscription to another storage account in another Azure subscription.

The scenario is the following:

You need to copy large files across many directories from one storage account in one subscription to another storage account in another Azure subscription, and both are in the same region. This could be in another Azure region as well, but the performance won’t be the same.

How to Copy Files From One Azure Storage Account to Another 1

For this scenario, we will make use of the AzCopy tool which is a command-line utility that you can use to copy blobs or files to or from a storage account. If you are new to this tool, then make sure to check the get started document from Microsoft here.

Prerequisites

The prerequisites are very simple as follows:

1) Download AzCopy v10.13.x, or jump into the Azure Cloud Shell session, AzCopy is included as part of the cloud shell.

2) Download Microsoft Azure Storage Explorer if you don’t have it yet, we will use it to create the Shared Access Signature (SAS) tokens. You can also generate SAS tokens using the Azure Portal, as well as using PowerShell. Personally, I prefer to use Azure Storage Explorer to generate SAS tokens. As a side note, SAS is more secure than the storage account key.

One of the main reasons is with SAS, you can ACL the IPs that can access the account, you can control the permissions on the account in a more granular fashion, and when the token will expire, as well as which service you want to have access to (Blobs, Files, Queues, Tables). Please note that SAS tokens are signed with your key, so invalidating your storage account key should invalidate the SAS token as well, so keep that in mind.

How to Copy Files From One Azure Storage Account to Another 2

Copy Files Between Azure Storage Accounts

Once you have everything in place, you are ready to go.

Before starting to copy data, let’s check the content of the blob in the source and the target storage account.

Source Storage Account

In the source storage account, I have two containers and one file in each.

How to Copy Files From One Azure Storage Account to Another 3

Target Storage Account

In the target storage account in the second subscription, I don’t have any containers yet.

How to Copy Files From One Azure Storage Account to Another 4

To copy an entire account data from one blob account with SAS to another blob account with SAS, you can use the following syntax. This command will go through all containers from one blob in recursive mode and copy all the contents to the second storage account.

azcopy copy "https://[sourceaccount].blob.core.windows.net?[SAS]" "https://[targetaccount].blob.core.windows.net?[SAS]" --recursive=true

The output will show the total number of Transfers, Completed, and Failed as well as the time in Minutes.

How to Copy Files From One Azure Storage Account to Another 5

Refresh the Azure Storage Explorer, then check the containers and their content are copied over.

How to Copy Files From One Azure Storage Account to Another 6

There’s more…

You can also use AzCopy in Azure Storage Explorer to copy data between storage accounts, if you want to leverage the performance advantages of AzCopy in Storage Explorer, then make sure to enable it under the Preview tab as shown in the following screenshot.

How to Copy Files From One Azure Storage Account to Another 7

It this great to copy a small number of directories and files between storage accounts, but for a large number of files, the AzCopy command-line tool is the fastest option. You can also use the same approach described above to copy and transfer Azure file shares between accounts.

That’s it there you have it.

Summary

In this article, we showed you how to copy files from one Azure Storage account to another storage account using the AzCopy command-line tool.

To learn more about syncing between Azure File share(s) and Azure Blob Container, check the following article.

To learn more about syncing between two Azure File share(s) for disaster recovery, check the following article.

__
Thank you for reading my blog.

If you have any questions or feedback, please leave a comment.

-Charbel Nemnom-

Photo of author
About the Author:
Charbel Nemnom
Charbel Nemnom is a Senior Cloud Architect with 21+ years of IT experience. As a Swiss Certified Information Security Manager (ISM), CCSP, CISM, Microsoft MVP, and MCT, he excels in optimizing mission-critical enterprise systems. His extensive practical knowledge spans complex system design, network architecture, business continuity, and cloud security, establishing him as an authoritative and trustworthy expert in the field. Charbel frequently writes about Cloud, Cybersecurity, and IT Certifications.
Previous

Passed AZ-500 Exam: Microsoft Certified Azure Security Engineer

How to Find The Recovery Services Vault for an Azure VM with PowerShell

Next

4 thoughts on “How to Copy Files From One Azure Storage Account to Another”

Leave a comment...

  1. Hello Sabhyata, thanks for the comment!
    Please note that AzCopy is NOT supported yet for NFS 4.1 feature enabled on the Azure storage account.
    At the moment, you need to search for trusted open-source projects.
    Thanks!

  2. Hello Charbel, does data traverse over internet when we use AzCopy for data transfer from on-premises to Azure? and if yes, can we restrict AzCopy to use S2S VPN or ExpressRoute? Thanks!

  3. Hello Madhu, thanks for the comment and the good question!
    By default, AzCopy uses the Internet when you transfer data from on-premises to Azure. However, if you are transferring between two storage accounts, then it will use the Azure backbone network.
    Now to restrict AzCopy to use S2S VPN or ExpressRoute, you need to configure and enable the Private Endpoint for the storage account.
    Next, you need to make sure that you can resolve the private endpoint DNS (StorageAccount.privatelink.blob.core.windows.net) from on-premises over the private IP address.
    For this you can use a DNS forwarder to resolve the Azure service public DNS zone in Azure, or you can use the new Azure DNS Private Resolver for on-premises workload.
    Once the network is configured properly for the storage account, then you can use AzCopy over S2S VPN or ExpressRoute.
    Hope it helps!

Let us know what you think, or ask a question...