AzCopy Command-Line Tool is used to transfer data to/from storage accounts and also from on-premise and storage accounts. Here, we will briefly explain some basic task using Azure command-line tool for data transfer.
Follow the below steps to perform a simple data migration between a local-PC and Azure Storage.
Download a BLOB from Azure:
1) Download AzCopy Command-Line Tool from here and install it.
2) Navigate to Azure storage container from Azure portal and copy the container URL and paste it in a notepad.
3) Navigate to access key and copy a key to notepad.
4) This is the format of AZCopy command:
AzCopy /Source: https://myaccount.blob.core.windows.net/mycontainer /Dest:C:\myfolder /SourceKey:key /Pattern:"abc.txt"
Let’s take a close look at the command parameters.
/Source: This is the URL of the storage container
/ Dest: This is the location where the file should be saved on the local PC
/ SourceKey: This the access key of the storage account
/ Pattern: The name of the file to be downloaded
Replace all the source and source key elements in the command with the one we copied from step 3 and 4. For destination, we have created a folder named “az” in C Drive and download a file named ”test.txt”.
So, the final command after replacing the values will be like this:
AzCopy /Source:https://sysallystorage.blob.core.windows.net/test /Dest:C:\az /SourceKey:N/dwDCqQQPdlqyZsvZQpYcZmuI9r5AiD26ByU4aY6Dp9NPavGrmVTZSIcFsdfCI5 cQTPyjDZQs8ap7CtvGSxbA== /Pattern:"test.txt"
5) Open the AzCopy Command-Line Tool and paste the above command there and press enter. Once the transfer is completed, you can see the details of file transfer.
6) Open the destination folder and you can see the downloaded file there.
Upload File to Azure BLOB
1) To upload a file to Azure BLOB, We can use the below format:
AzCopy /Source:C:\myfolder /Dest:https://myaccount.blob.core.windows.net/mycontainer
/DestKey:key /Pattern:"abc.txt”
The parameters are same as in the previous step. The only difference is source will be the location of the file on the local PC and destination path is the URL of Azure Container. Here, I am uploading a file called “upload.txt”.
The final command will be like this:
AzCopy /Source:C:\az /Dest:https://sysallystorage.blob.core.windows.net/test
/DestKey:N/dwDCqQQPdlqyZsvZQpYcZmuI9r5AiD26ByU4aY6Dp9NPavGrmVTZSIcFsdfCI5cQ
TPyjDZQs8ap7CtvGSxbA== /Pattern:"upload.txt"
2) Open the tool and paste the command and press enter.
Now, you can see the summary of file transfer once it is completed.