Using Azcopy On Linux To Put Files In Azure Storage

Linux is everywhere in the cloud, and it is high time I start digging in more and working with it. I am sure this will be a long process, but here goes nothing.

Sometimes there are files that you end up with on a linux vm and you need them to be in Azure Storage so other things (or users) can consume them.

Azure has a slick tool called AzCopy that allows files to be copied to and from Azure Storage. The first thing to do is get the application installed on to your vm:

  1. Use wget to download the file from here
     sudo wget
     sudo tar -xvf downloadazcopy-v10-linux
     cd /azcopy 
     sudo cp azcopy /usr/bin
     sudo azcopy --version
  2. Locate the file on the vm that you wish to copy to azure storage and cd to that directory
  3. In the azure portal, browse to or create a storage account to use.
  4. Create a container called files (or use an existing container)
  5. From the list of containers, select the ellipsis menu on the right end of the row and choose Create SAS URL
  6. Specify the permissions needed (Write, Add, Create, Read, List)
  7. Click Generate SAS token and URL and copy the SAS URL
  8. Back on the linux vm execute the following command to copy the file:

    azcopy copy ./thefile.txt “SAS URL”

When the file transfer completes, check the Azure portal to see that the copy has completed. That is pretty much all there is to moving files from a linux vm to Azure Storage.

The URLs have been left out to not expose any actual storage - just in case. Images may be added later.

Additional documentation about Azure Blob Storage can be found here

Written on May 12, 2022