AzCopy - copy files from on-premise location to Azure Blog Storage (ADLS)

Today we will learn on how to copy files from on-premise to Azure Blob Storage (ADLS) using AzCopy


Pre-Requisite:
  • Download AzCopy utility from here  (microsoft site)
  • Install the AzCopy.exe in the machine that you'll be using to run the copy commands
  • Open the Azcopy command line utility and start writing the commands
Steps to deploy AzCopy Script to copy Images:
  1. Authenticate a user identity:
    1. Use the script in CMD to authenticate your identity.


    • Replace the <tenant-id> placeholder with the tenant ID of the organization to which the storage account belongs. To find the tenant ID, select the Azure Active Directory > Properties > Directory ID in the Azure portal.

    • Eg.: azcopy login --tenant-id = 5dasda9fa7da79da7-abec-4505-81ea6-8csda2


Once you enter the command "azcopy login --tenant-id = <tenant-id>, it will return a code and URL of a website.
  • Open the website
  • Provide the code
  • Click Next button
  • A Sign-in window will appear.
  • Sign-in using your azure account credentials
  • After you've successfully signed in, you can close the browser window and begin using AzCopy
To login using other means (service principle or User assigned identity), get the appropriate command from the below link:
      
2. To copy files from On-prem location to ADLS, use the below command:
  • azcopy sync " <Select-folder-path>" "https:// <storage-account-name>/ <container-name> <SAS Token>" --recursive=true 
Note: Please use double quotation for file path if you’re using Windows machine. 
  • AzCopy sync will start a non-stop copy process where AzCopy will keep on copying the files unless manually terminated.
  • If you just want to just trigger the process one time, use the copy parameter instead of sync.
Copy single file:
  • azcopy cp "/path/to/file.txt" "https://[account].blob.core.windows.net/[container]/[path/to/blob]?[SAS]"
Copy entire directory:
  • azcopy cp "/path/to/dir" "https://[account].blob.core.windows.net/[container]/[path/to/directory]?[SAS]" --recursive=true
To get the SAS token:
  • Go to your storage account from Azure Portal
  • Click Shared Access Signature 
  • Copy the SAS token



1 comment:

  1. Azcopy is great but ShareGate and Gs Richcopy 360 are more easy and full featured

    ReplyDelete