How to copy data in Azure using AzCopy
Tags: azure, video, tutorial, cloud
Published: 2021-02-25 14:03:52

---
title: How to copy data in Azure using AzCopy
published: true
date: 2021-02-25 13:56:00 UTC
tags: azure,video,tutorial,cloud
canonical_url: http://www.frankysnotes.com/2021/02/how-to-copy-data-in-azure-using-azcopy.html
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7minje20470ceow23nk4.jpg
---

Data is the key to almost all solutions. Obviously, at some point, we will need to move it. And this is when [AzCopy](https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-v10?WT.mc_id=frankysnotes-blog-frbouche) 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
```
 

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](https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-user-delegation-sas-create-cli?WT.mc_id=frankysnotes-blog-frbouche)) 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](https://1.bp.blogspot.com/-Dkw7GW6wlv4/YDepjyPLX5I/AAAAAAABd7w/npnLzczPgiAgwG-zj3Su7MGua3mYEfsBwCLcBGAsYHQ/w400-h281/sasToken.png "Create a SAS token")](https://1.bp.blogspot.com/-Dkw7GW6wlv4/YDepjyPLX5I/AAAAAAABd7w/npnLzczPgiAgwG-zj3Su7MGua3mYEfsBwCLcBGAsYHQ/s2048/sasToken.png)
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

{% youtube u5s-aEU2Yi0 %}

### 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](http://www.frankysnotes.com/2016/04/how-to-transfert-data-between-azure.html). There is also a video for this one [https://youtu.be/cE8qwnSk9qs](https://youtu.be/cE8qwnSk9qs)

#### References:

- AzCopy: [https://aka.ms/azcopy](https://aka.ms/azcopy) 
- [Az CLI Generate SAS token](https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-user-delegation-sas-create-cli?WT.mc_id=frankysnotes-blog-frbouche)

  
~Frank