Transfer data with AzCopy and Blob storage

In this article

AzCopy is a command-line utility that you can use to copy data to, from, or between storage accounts. This article contains example commands that work with Blob storage.

Get started

See the Get started with AzCopy article to download AzCopy and learn about the ways that you can provide authorization credentials to the storage service.

Note

The examples in this article assume that you've authenticated your identity by using the AzCopy login command. AzCopy then uses your Azure AD account to authorize access to data in Blob storage.

If you'd rather use a SAS token to authorize access to blob data, then you can append that token to the resource URL in each AzCopy command.

For example: https://<storage-account-name>.blob.core.windows.net/<container-name>?<SAS-token>".

Create a container

You can use the AzCopy make command to create a container. The examples in this section create a container named mycontainer.

Syntax

azcopy make "https://<storage-account-name>.<blob or dfs>.core.windows.net/<container-name>

Example

azcopy make "https://mystorageaccount.blob.core.windows.net/mycontainer"

Example (hierarchical namespace)

azcopy make "https://mystorageaccount.dfs.core.windows.net/mycontainer"

Upload files

You can use the AzCopy copy command to upload files and directories from your local computer.

This section contains the following examples:

Upload a file

Upload a directory

Upload files by using wildcard characters

Note

AzCopy doesn't automatically calculate and store the file's md5 hash code. If you want AzCopy to do that, then append the --put-md5 flag to each copy command. That way, when the blob is downloaded, AzCopy calculates an MD5 hash for downloaded data and verifies that the MD5 hash stored in the blob's Content-md5 property matches the calculated hash.

Download files

You can use the AzCopy copy command to download blobs, directories, and containers to your local computer.

This section contains the following examples:

Download a file

Download a directory

Download files by using wildcard characters

Note

If the Content-md5 property value of a blob contains a hash, AzCopy calculates an MD5 hash for downloaded data and verifies that the MD5 hash stored in the blob's Content-md5 property matches the calculated hash. If these values don't match, the download fails unless you override this behavior by appending --check-md5=NoCheck or --check-md5=LogOnly to the copy command.

Copy blobs between storage accounts

You can use AzCopy to copy blobs to other storage accounts. The copy operation is synchronous so when the command returns, that indicates that all files have been copied.

AzCopy uses server-to-serverAPIs, so data is copied directly between storage servers. These copy operations don't use the network bandwidth of your computer. You can increase the throughput of these operations by setting the value of the AZCOPY_CONCURRENCY_VALUE environment variable. To learn more, see Optimize throughput.

Note

This scenario has the following limitations in the current release.

Only accounts that don't have a hierarchical namespace are supported.

You have to append a SAS token to each source URL. If you provide authorization credentials by using Azure Active Directory (AD), you can omit the SAS token only from the destination URL.

Premium block blob storage accounts don't support access tiers. Omit the access tier of a blob from the copy operation by setting the s2s-preserve-access-tier to false (For example: --s2s-preserve-access-tier=false).

This section contains the following examples:

Copy a blob to another storage account

Copy a directory to another storage account

Copy a containers to another storage account

Copy all containers, directories, and files to another storage account

Synchronize files

You can synchronize the contents of a local file system with a blob container. Synchronization is one-way. In other words, you choose which of these two endpoints is the source and which one is the destination. Synchronization also uses server to server APIs.

Note

Currently, this scenario is supported only for accounts that don't have a hierarchical namespace. The current release of AzCopy doesn't synchronize between other sources and destinations (For example: File storage or Amazon Web Services (AWS) S3 buckets).

The sync command compares file names and last modified timestamps. Set the --delete-destination optional flag to a value of true or prompt to delete files in the destination directory if those files no longer exist in the source directory.

If you set the --delete-destination flag to true AzCopy deletes files without providing a prompt. If you want a prompt to appear before AzCopy deletes a file, set the --delete-destination flag to prompt.

Note

To prevent accidental deletions, make sure to enable the soft delete feature before you use the --delete-destination=prompt|true flag.

Update a container with changes to a local file system

In this case, the container is the destination, and the local file system is the source.