How to transfer files to Azure File Share (AzCopy)

We recently had a requirement to save large files from a Linux VM to a separate location, we chose an Azure File Share as a staging area. To achieve this via command line you can use the AzCopy Tool.

To get started you will need an Azure Storage Account – details on how to create one can be found in the quick start article.

    Next you will need a file share:
  1. From your Azure Storage account Overview page select the File Shares option.
  2. Select add a file share.
  3. Name your file share and give it a quota if needed, make a note of the name as this will be needed later.
    We will be using a shared access signature with AzCopy so next step is to generate one.
  1. Go back to your storage account and choose the “Shared Access Signature” option in the left panel under the settings options.
  2. Customise the permissions as necessary ensuring read and write is selected, then select the “Generate SAS and connection String”.
  3. Copy and make a note of the “File service SAS URL” as this will be required later and will not be shown again.
    Now head back to your Linux VM and download AzCopy:
  • Download AzCopy
  • Expand Archive
    • tar -xvf downloadazcopy-v10-linux
  • Move AzCopy to the destination you want to store it
    • sudo cp ./azcopy_linux_amd64_*/azcopy /usr/bin/

           Note you can remove this and previous versions of AzCopy with:

  • sudo rm /usr/bin/azcopy


    Now prepare your command, you will need:
  • Storage Account Name
    • mystorageaccount
  • File Share name
    • myfileshare
  • Local File Name
    • .\myTextFile.txt
  • Destination File Name
    • myTextFiletxt


    To Upload a File:

azcopy copy “<local-file-path>” https://<storage-account-name><file-share-name>/<file-name>?<SAS-token>


azcopy copy “.\myTextFile.txt” “


To Download a File:

azcopy copy “https://<storage-account-name><file-share-name>/<file-path>?<SAS-token>” “<local-file-path>

azcopy copy “” “.\myTextFile.txt


Note: you only need the bit after the ? of your SAS URL.

To download/upload files in bulk simply remove the destination file name and use a directory with * wildcard with the –recursive switch.

Use “azcopy -h” for assistance.

Hope this helps

About the author