Upload file to Azure

?
S
Bash

You can adapt your AWS S3 script to work with Azure Storage and use cron to schedule the execution. Azure Blob Storage uses a different authentication approach (SAS tokens) and different APIs, so the code to upload files is different. Here's a basic example of how you can do this with a bash script and Azure CLI, which is assumed to be installed and configured CRONTAB (run the script at 22:00 (10 PM) on the fifth day of the week (Friday): 0 22 * * 5 /path/to/your/script.sh

1#!/bin/bash
2# Array of files to upload
3files=("file1.txt" "file2.txt" "file3.txt")
4
5# Azure Storage account and container details
6storageAccount="yourStorageAccount"
7container="yourContainer"
8
9# Loop through files and upload each one
10for file in "${files[@]}"
11do
12   echo "Uploading ${file}"
13   az storage blob upload --account-name $storageAccount --container-name $container --name $file --type block --file $file --connection-string "your-connection-string"
14done

Created on 10/10/2023