Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
You can incorporate AzCopy into automated scripts for batch operations, scheduled data transfers, or continuous integration pipelines. This article shows you how to obtain static download links to ensure version consistency, create scheduled tasks for automated data transfers, and handle special considerations like character escaping and Jenkins integration.
Obtain a static download link
Over time, the AzCopy download link points to new versions of AzCopy. If your script downloads AzCopy, the script might stop working if a newer version of AzCopy modifies features that your script depends upon.
To avoid these issues, get a static (unchanging) link to the current version of AzCopy. That way, your script downloads the same exact version of AzCopy each time that it runs.
To get a static link, open the AzCopy release page. Then, scroll through the page until you locate the desired release. In the list of assets for that release, right-click the desired asset. In the context menu, select Copy link. You can then use that URL in your script to download and extract the AzCopy binary.
Note
The static link to AzCopy binaries can change over time due to our content delivery infrastructure. If you must use a specific version of AzCopy for any reason, consider using AzCopy with an operating system that leverages the Linux published package. This method ensures that you can reliably install and maintain the desired version of AzCopy.
Create a scheduled task
You can create a scheduled task or cron job that runs an AzCopy command script. The script identifies and uploads new on-premises data to cloud storage at a specific time interval.
The following examples assume that you configured Microsoft Entra authentication by using the AZCOPY_AUTO_LOGIN_TYPE environment variable. To learn more, see Authorize with Microsoft Entra ID.
Copy the following AzCopy command to a text editor. Update the parameter values of the AzCopy command to the appropriate values. Save the file as script.sh.
azcopy sync "/mnt/myfiles" "https://mystorageaccount.blob.core.windows.net/mycontainer" --recursive=true
You can create a cron job by using the Crontab command. The following example creates a cron job and specifies the cron expression */5 * * * * which indicates that the shell script script.sh should run every five minutes.
crontab -e
*/5 * * * * sh /path/to/script.sh
You can schedule the script to run at a specific time daily, monthly, or yearly. To learn more about setting the date and time for job execution, see cron expressions.
Escape special characters in SAS tokens
In batch files that have the .cmd extension, you need to escape the % characters that appear in SAS tokens. Add an extra % character next to existing % characters in the SAS token string. The resulting character sequence appears as %%. Add an extra ^ before each & character to create the character sequence ^&.
Run scripts by using Jenkins
If you plan to use Jenkins to run scripts, place the following command at the beginning of the script.
/usr/bin/keyctl new_session
Next steps
If you have questions, issues, or general feedback, submit them on GitHub.