Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upload multi file from linux folder to Azure Blob Storage


now in Linux VM, I upload a single file with this command:
azure storage blob upload -q /folder/file.txt --container containerName

Is possible upload more file at the same time? (with a single command)

like image 602
Carlo Camusso Avatar asked Mar 17 '23 20:03

Carlo Camusso


2 Answers

You can use a loop like so

#!/bin/bash

export AZURE_STORAGE_ACCOUNT='your_account'
export AZURE_STORAGE_ACCESS_KEY='your_access_key'

export container_name='name_of_the_container_to_create'
export source_folder=~/path_to_local_file_to_upload/*


echo "Creating the container..."
azure storage container create $container_name

for f in $source_folder
do
  echo "Uploading $f file..."
  azure storage blob upload $f $container_name $(basename $f)
  cat $f
done

echo "Listing the blobs..."
azure storage blob list $container_name

echo "Done"
like image 134
ulrich Avatar answered Apr 27 '23 22:04

ulrich


The command line does not have an option to bulk upload multiple files in one invocation. However, you can either use find or a loop to upload multiple files, or if doing this from Windows is an option, then you can look at using the AzCopy tool (http://aka.ms/azcopy).

like image 31
Atul Sikaria Avatar answered Apr 27 '23 21:04

Atul Sikaria