Configure AzCopy to copy/sync files from local directory to container on Azure Stack & Run AzCopy as scheduled task.
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 data.
DOWNLOAD AND RUN AZCOPY
Step 1: Download AzCopy from:
https://aka.ms/downloadazcopy-v10-windows (Windows 64-bit)
https://aka.ms/downloadazcopy-v10-windows-32bit (Windows 32-bit)
Step 2: Extract the files; copy the “azcopy.exe” application files.
Step 3: Create a new folder in C drive and paste the “azcopy.exe” file in it. (Note: this new folder is where you would save the runnable AzCopy batch file.)
Step 4: Create another folder in C drive which should contain the files you want to copy/sync to the Storage Account.
Step 5: Navigate to “System Variables” on your computer to add a new System Variable with the following values:
Variable: AZCOPY_DEFAULT_SERVICE_API_VERSION
Value: 2017-11-09
Step 6: Navigate to the container on Azure Stack; select Properties; copy the container URL
Step 7: Navigate to the Storage Account on Azure Stack; select Shared Access Signature (Under "Allowed resource types", ensure that the container and object buttons are ticked); set the required time start and expiry date/time; click on "Generate SAS and Connection String"; copy the SAS token.
Step 8: Navigate to the “azcopy.exe” application file on C drive and copy its location.
Step 9: Navigate to the folder (source directory) containing the files to be copied/synced to the storage account and copy its location.
Step 10: Using a notepad, combine the results from steps 6, 7, 8 and 9 above to make up a script. The script should have the following syntax:
<location of azcopy.exe file>\azcopy.exe sync "<location of folder containing the files to be copied/synced>" "<URL of container>/<SAS token of storage account>" –recursive
Step 11: Launch "PowerShell"; navigate to the location of the “azcopy.exe” file and paste the command-line generated from Step 10 above.
Notice that the command runs with a status of "completed". Now check the container on Azure Stack to confirm its content.
RUN AZCOPY AS A SCHEDULED TASK
Step 12: Modify the script from Step 10 above; replace all % with %% and all & with ^&; remove the quotes around the container URL and SAS token.
Step 13: Save the script above as a batch file (.bat); move it to the folder containing the azcopy.exe application file.
Step 14: Launch "Task Scheduler"; click on "Create Basic Task"; follow through with the process; upload the batch file from Step 12 above.
Notice that the task runs at the scheduled times.
Update the source directory just before the next run.
Check the container on Azure Stack to confirm its content after every update made in the source directory.