AzCopy is a command-line utility that you can use to copy blobs or files to or from a storage account. This article helps you download AzCopy, connect to your storage account, and then transfer files.
Microsoft Documentation
Download here: https://aka.ms/downloadazcopy-v10-windows
The download has the zip that contains the azcopy executable. Download, extract and move the executable to some folder on your system and add its location to the system path for convenience.
Based on what you need to do you will probably require some metadata/information from your azure portal. In this article I’ll be showing example on how to:
- Copy files from local to a blob container in azure
- Copy files from one container to another.
You can use following powershell commands to get some of this information:
- Login to your azure account: Connect-AzureRmAccount. This will launch a window for you to provide your azure credentials. If successful you should get following information in the response:
- Account
- Subscription Name
- Subscription Id
- Tenant Id
- Environment
- Get list of storage accounts in your account: Get-AzureRmStorageAccount
- Or create a new storage account using New-AzureRmStorageAccount
Using AzCopy
- To use azcopy first you need to login to azure. Run following command:
- azcopy login –tenant-id “<Tenant Id from step 1.d>”
- Next you will need to provision a blob container in your storage account to hold the files you’re copying. You can create container using following command:
- azcopy make https://<storage account name>.blob.core.windows.net/<container name>
- Copy files (from local):
- azcopy copy “<Local system path to folder containing files>\*” https://<storage account name>.blob.core.windows.net/<container name>/
- If you would like to copy all folders and files under them then add –recursive flag
- Copy files (from container)
- When you copy files from one container to another then you need to pass Shared Access Signature (SAS) token from the source container.
- SAS token can be created from Storage Account -> Shared Access Signature
- azcopy copy “https://<source storage>.blob.core.windows.net/<source container>/?<SAS Token>” “https://<target storage>.blob.core.windows.net/<target container>/” –recursive
Some other useful links for reference:
- AzCopy Command Reference: https://docs.microsoft.com/en-us/azure/storage/common/storage-ref-azcopy
- Microsoft Azure Storage Explorer: A great tool to work with storage accounts. https://azure.microsoft.com/en-us/features/storage-explorer/