---
title: "Transfer Files with AzCopy: OAuth and SAS Token"
description: "Master AzCopy to transfer files between local and Azure storage using OAuth and Shared Access Signature Token. Enhance your cloud management skills."
canonical: "https://adamtheautomator.com/azcopy/"
---

# Transfer Files with AzCopy: OAuth and SAS Token

> Master AzCopy to transfer files between local and Azure storage using OAuth and Shared Access Signature Token. Enhance your cloud management skills.

Source: https://adamtheautomator.com/azcopy/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Transfer Files with AzCopy: OAuth and SAS Token](https://adamtheautomator.com/wp-content/uploads/2019/12/azcopy.png)

# Transfer Files with AzCopy: OAuth and SAS Token

[![](https://secure.gravatar.com/avatar/9a14f10ff1b1ec7d790d34f5b559e4d3de2d31b172e6ef266dfd8b479174d97b?s=192&d=mm&r=g)June Castillote](https://adamtheautomator.com/author/june/)23 December 20196 min. read

Categories: [Cloud](/category/cloud/)

Tags:[Azure Storage Accounts](/tag/azure-storage-accounts/)

Table of Contents

*   [Prerequisites](#prerequisites)
*   [Creating New Storage Containers](#creating-new-storage-containers)
*   [Copying Files to/from Azure Containers](#copying-files-to-from-azure-containers)
*   [Using OAuth Authentication](#using-oauth-authentication)
*   [Using a Shared Access Signature (SAS) Token](#using-a-shared-access-signature-sas-token)
*   [Copying a Directory to/from Azure Storage](#copying-a-directory-to-from-azure-storage)
*   [Copying Files Between Azure Storage Containers](#copying-files-between-azure-storage-containers)
*   [Other Useful AzCopy Operations](#other-useful-azcopy-operations)
*   [Summary](#summary)

Automation is everywhere nowadays in IT. From virtual machine provisioning to web site deployment, automation is key especially when you need to deal with multiple items. Even file management between Azure storage and your local machine can be automated using a utility program called [AzCopy](https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-v10).

Not a reader? Watch this related video tutorial!

**_Not seeing the video? Make sure your ad blocker is disabled._**

AzCopy is a standalone utility that allows the management of Azure storage. With AzCopy, several operations can be performed. In this article, we’re going to focus on:

*   Creating [storage containers](https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blobs-introduction#containers)
*   Copying local files to containers
*   Copying files between containers

Let’s begin!

If you learn better via video, you can also check out a TechSnips video closely related to what you’ll be learning in this article.

## Prerequisites

This article will a walkthrough demonstrating various tasks. If you’d like to follow along, be sure you have the below list of requirements met before starting.

*   An Azure subscription. If you do not have this yet, you can [request for a trial subscription](https://azure.microsoft.com/en-us/free/).
*   Azure Storage Account. Please refer to [Create a storage account](https://docs.microsoft.com/en-us/azure/storage/common/storage-account-create?tabs=azure-portal) to learn more.
*   AzCopy downloaded and authenticated (check out the article [_How to Download and Install the AZCopy Tool_](https://adamtheautomator.com/azcopy-download/) to learn how to set this up)

## Creating New Storage Containers

First up, let’s use AzCopy to create new storage containers in an existing storage account. In the example you’ll be using, you’ll create two new containers named _container1_ and _container2_.

> _Note: Before creating a new container, you must know the container’s endpoint URL. The endpoint URL adheres to the format: https://\[storageaccountname\].blob.core.windows.net/\[container\_name\]._

First, define the endpoint URL. In this example, the containers will be created in a storage account called _storageaccount1207_ creating two endpoint URLs:

*   [_https://storageaccount1207.blob.core.windows.net/container1_](https://storageaccount1207.blob.core.windows.net/container1*)
*   [_https://storageaccount1207.blob.core.windows.net/container2_](https://storageaccount1207.blob.core.windows.net/container2*)

Now that you know the endpoint URLs, use the `azcopy make` command passing each endpoint URL as a parameter as shown below.

```bash
> azcopy make https://storageaccount1207.blob.core.windows.net/container1
> azcopy make https://storageaccount1207.blob.core.windows.net/container2
```

![Creating new containers in the storageaccount1207 storage account](/wp-content/uploads/2019/12/rId63.png)

Creating new containers in the storageaccount1207 storage account

## Copying Files to/from Azure Containers

Once you have a storage container created, you’re probably asking “How do I upload to Azure Blob Storage?”.  You can make it happen with AzCopy using the `azcopy copy` command. You can use AzCopy to copy PSTs, VHDs, and more.

Related: [How to Use Blob Storage via Azure File Storage](https://adamtheautomator.com/blob-storage/)

### Using OAuth Authentication

When using AzCopy to copy files to blobs, you have a couple of options for authentication. Since it is presumed you’ve already authenticated to Azure Storage (since it was in the prerequisites), you can simply run `azcopy copy` specifying a local file path followed by a container endpoint URL as shown below.

By not specifying any other parameter, you are using the OAuth authentication.

```bash
> azcopy copy c:\myDir\file1.txt https://storageaccount1207.blob.core.windows.net/container1
```

![Upload file to Azure Storage using OAuth](/wp-content/uploads/2019/12/rId74.png)

Upload file to Azure Storage using OAuth

How do you know to confirm the file is copied to the Azure blob container? You can use the `azcopy list [container url]` command. See the example below showing that the `file1.txt` file exists.

```bash
> azcopy list https://storageaccount1207.blob.core.windows.net/container1
```

![List the contents of the Azure blob container](/wp-content/uploads/2019/12/rId75.png)

List the contents of the Azure blob container

To download a file from the Azure blob to the local directory, you only need to switch the places of the source and destination arguments. See the example below.

```bash
> azcopy copy https://storageaccount1207.blob.core.windows.net/container1/file1.txt>c:\myDir
```

![Download file from Azure Storage using OAuth authentication](/wp-content/uploads/2019/12/rId76.png)

Download file from Azure Storage using OAuth authentication

### Using a Shared Access Signature (SAS) Token

To use a SAS token, you must first generate one. If you don’t know how to generate a SAS token, check out the [How to Generate an Azure SAS Token to Access Storage Accounts article](https://adamtheautomator.com/azure-sas-token/).

Once you have a SAS token available, you can append the token to the destination container’s URL as an HTTP parameter as shown below.

```bash
> azcopy copy c:\myDir\file1.txt 'https://storageaccount1207.blob.core.windows.net/container1?sv=2019-02-02&sr=c&sig=LgFsqIRHZovsSjpAVNAyyyy4tnDJ%2BxNh%2B1Cq3rY4Gbk%3D&se=2019-12-09T06%3A34%3A30Z&sp=rw'
```

If you are using PowerShell and stored the token to a variable (eg. `$token`), you can pass that variable as instead of the full token string like the command below.

```bash
> azcopy copy c:\myDir\file1.txt "https://storageaccount1207.blob.core.windows.net/container1?$token"
```

![Copy file to Azure Container using SAS Token Authentication](/wp-content/uploads/2019/12/rId78.png)

Copy file to Azure Container using SAS Token Authentication

Using the same token (assuming it is still within its validity period), you can also download files from the Azure storage to the local storage. The example below copies the `file1.txt` file from the Azure storage with a SAS token.

In the code below, you can see that this time instead of appending the token after the container name, the name of the file is added first. This instructs AzCopy to copy a specific file using the SAS authentication.

```bash
> azcopy copy ('https://storageaccount1207.blob.core.windows.net/container1/file1.txt'+$token) C:\MyDir\
```

![Copy file from Azure Container with SAS Token](/wp-content/uploads/2019/12/rId79.png)

Copy file from Azure Container with SAS Token

## Copying a Directory to/from Azure Storage

If you have many files to transfer or download from Azure, you can also copy entire directories at once using `azcopy copy`. The command to do so is not that different from what you use to copy single files.

Related: [How to Set up Azure File Sync to Sync On-Prem to Azure \[Step-by-Step\]](https://adamtheautomator.com/azure-file-sync/)

Below you can see a command that copies the `C:\\MyDir` recursively to the blob container _container1_. The `--recursive` parameter is the key here. The `—recursive` flag at the end of the command indicates that all contents from the parent directory and sub-directories that may exist will be copied.

```bash
> azcopy copy C:\MyDir\ https://storageaccount1207.blob.core.windows.net/container1/ --recursive
```

You can see below ten files inside of _C:\\MyDir_ folder were all copied successfully based on the job summary.

![Copying a directory and its contents](/wp-content/uploads/2019/12/rId81.png)

Copying a directory and its contents

## Copying Files Between Azure Storage Containers

Throughout this article, you’ve been using the `azcopy copy` command quite a bit. There’s no need to stop now! Not only can you copy directories and files to/from on-prem, you can also copy blobs across storage containers.

Rather than using a local file path, you’d change up the parameters to use one blob container URL as the source and another blob container URL as the destination.

You’ve already created two storage containers called _container1_ and _container2_. In this section, let’s copy files, directories and even the entire blob container from _container1_ to _container2_.

To copy files from one container to another, first, generate a new SAS token. Since the two containers belong to the same storage account, the same token can be used for both the source and destination.

Assuming you’ve saved the token string to a variable called `$token` (if running _azcopy_ with PowerShell), you can easily copy all data from one storage container to the other as shown below.

> _Reminder: Take a look at the [How to Generate an Azure SAS Token to Access Storage Accounts](https://adamtheautomator.com/azure-sas-token/) article if you don’t know how to generate a SAS token._

```bash
> azcopy copy ('https://storageaccount1207.blob.core.windows.net/container1'+$token) ('https://storageaccount1207.blob.core.windows.net/container2'+$token) --recursive
```

![Copying data between containers using SAS Token authentication](/wp-content/uploads/2019/12/rId84.png)

_Copying data between containers using SAS Token authentication_

## Other Useful AzCopy Operations

Aside from copying files and folders, there are other copy operations you can perform with AzCopy. Some of these are:

*   Copying specific files (filtered).
*   Copying a directory into another directory in the blob container.
*   Copying from Amazon AWS to Azure Storage.

If you’d like to learn about everything AzCopy can do, check out the help content by running `azcopy -h`. You’ll find many other useful commands aside from the `copy` command you’ve focused solely on in this article. You can see a screenshot of these commands below.

![List of AzCopy Commands](/wp-content/uploads/2019/12/rId86.png)

List of AzCopy Commands

To learn more, visit the [_AzCopy Copy_](https://docs.microsoft.com/en-us/azure/storage/common/storage-ref-azcopy-copy) page. Then you can try these on your own using the techniques you learned in this article.

## Summary

In this article, you learned how to use AzCopy to transfer files between the local and Azure storage. You also learned how to perform these tasks while using OAuth and Shared Access Signature Token for authentication. You’ve seen what other AzCopy commands are available and how to find them.

I hope this article has helped you get started with AzCopy and sparked your interest in using it more as part of your administration or development tasks. Thank you!

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fazcopy%2F&text=Transfer%20Files%20with%20AzCopy%3A%20OAuth%20and%20SAS%20Token)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fazcopy%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fazcopy%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2026/09/featured_image-1.webp)

### [Bicep: Never Hand-Write Azure ARM JSON Again](/azure-bicep-vs-arm-templates/)

Learn how Bicep simplifies Azure infrastructure deployment with domain-specific language, dependency inference, and reusable modules for cleaner IaC.

![](https://adamtheautomator.com/wp-content/uploads/publisher/3075d9c85b2b811696d7c3fb28215d5b/2632cbcaed949b31f4a9b4c4ea73d850076a5034cf55e309a5815dd451ab0388.webp)

### [Stop Scaling Azure SQL: Find Real Performance Issues](/azure-sql-performance-tuning/)

Use Azure's built-in diagnostics to find real performance bottlenecks in your Azure SQL Database instead of scaling up immediately.

![](https://adamtheautomator.com/wp-content/uploads/2026/08/featured_image-7.webp)

### [Build Azure Landing Zones That Prevent Cloud Sprawl](/build-azure-landing-zones/)

Build governed Azure landing zones end to end with the IaC accelerator: management group hierarchies, the eight design areas, Terraform and Bicep deployments,

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
