DEV Community

Cover image for How to copy data in Azure using AzCopy
Frank Boucher ☁
Frank Boucher ☁

Posted on • Originally published at frankysnotes.com on

How to copy data in Azure using AzCopy

Data is the key to almost all solutions. Obviously, at some point, we will need to move it. And this is when AzCopy will come to the rescue. In this short post/video I will share how you can securely copy a Zip file (aka. data), from one location (blob storage, AWS) to a blob storage in an Azure subscription (the same subscription or a different one).

What is AzCopy

AzCopy is a command-line utility that you can use to copy blobs or files to or from a storage account. It can run on Windows, Mac, and Linux. And... It's already available pre-install inside Cloud Shell!

How it works

AzCopy can do many things but let's focus on the "copy" feature. To copy a file from a location to another one here the command to execute:

azcopy copy https://url-source https://url-destination
Enter fullscreen mode Exit fullscreen mode

It look simple right? And it is. To keep it secure AzCopy can use Shared Access Signature (SAS) tokens. To get those in Azure you can execute a command (ex: az storage container generate-sas) or use the Azure Portal.

Once you are in the Azure portal open the account storage of your source or destination (you will have to to both).

Screen capture showing the steps to create a SAS token
From the option on the left search for Shared access signature or just sas and click on it. Select the type of options you need. A best practices is to allow the minimum requirements. If you know you are only moving files then unchecked the File, Queue, and Table. Same things for the resources types, permissions and expiry date/time. Once you done click the Generate SAS and connection string button.

Use those URL with the SAS token in your command, and voila!

Video demo

How about Az CLI and PowerShell

If you prefer copying or moving your files using native commands in Azure PowerShell and Az CLI it's also possible here a previous post about that: How to copy files between Azure subscription from Windows, Linux, OS X, or the cloud. There is also a video for this one https://youtu.be/cE8qwnSk9qs

References:

~Frank

Top comments (0)