Skip to content

TechDirectArchive

Hands-on IT, Cloud, Security & DevOps Insights

  • Home
  • About
  • Advertise With US
  • Reviews
  • Contact
  • Toggle search form
Home » AWS/Azure/OpenShift » Azure CLI: How To Upload Batch Files to Azure Storage Account

Azure CLI: How To Upload Batch Files to Azure Storage Account

Posted on 22/06/202204/09/2023 Imoh Etuk By Imoh Etuk No Comments on Azure CLI: How To Upload Batch Files to Azure Storage Account
Azure-Storage-1

If you use Azure CLI blob storage for static web hosting, you’ll probably want a way to automate uploading your website file content to the Azure storage account. According to Microsoft’s official document, the Azure Storage platform is Microsoft’s cloud storage solution for modern data storage scenarios. Azure Storage offers highly available, massively scalable, durable, and secure storage for a variety of data objects in the cloud.  Here are some interesting guides: how to configure Azure Monitor for VMs on Azure Stack Hub and How To Use Azure Key Vault secrets in Azure Pipelines.

Before now, one good option we normally used was the AzCopy utility. Fortunately, the az storage blob upload-batch command in the Azure CLI now allows for bulk file upload. You must place these in a container called $web (so make sure you surround that with single quotes in PowerShell). The $web container is created automatically as soon as you create your Storage Account on Azure. You also specify the name of the folder that will contain the files to be uploaded. Here we are uploading a full website application stored in a folder known as webfiles.

To learn more about Azure CLI, PowerShell Cmdlets, and Azure in general, see the following guides; how to use the Azure Cloud Shell, Azure CLI, and Azure PowerShell, How to Remove Azure VM: How to delete a Virtual Machine via the Azure Portal, and Azure virtual networks: How to prepare Azure and on-premises virtual networks using Azure CLI commands,

Please keep in mind that uploading files to Azure Storage using CLI will not delete any existing files. 

The Azure command-line interface (Azure CLI) is a set of commands used to create and manage Azure resources. The Azure CLI is available across Azure services and is designed to get you working quickly with Azure, with an emphasis on automation.

Uploading Bulk Files to Azure CLI Storage Account

To get along in this tutorial, the following prerequisites are necessary:

  1. Active Azure Subscription. If you don’t one, you can sign up here
  2. Azure CLI for Windows. You can download and install Azure CLI for Windows here
  3. Azure Storage Account with $web container created
  4. Clone or download a free website template and store the folder in the Desktop location on your PC

If you have the above requirements, proceed with me to the next steps.

Step 1 – Login into Azure Portal via Azure CLI for Windows

To do this, launch PowerShell on your PC. When the PowerShell Cmdlet Console opens up, type:

az login
Az-login
az login

After typing az login and press enter, a browser authentication window pops up, requiring you to enter the email and password associated with your Microsoft Azure Account. Once you enter these details, you will be automatically logged in.

Step 2 – Create Azure Resources such as Resource Group and Azure Storage Account

Create a Resource Group which is a logical folder where resources on Azure are stored. To create a Resource Group using the Azure CLI, run:

az group create --name $ResourceGroup --location $Region
RG-Created
Creating a Resource Group

The next thing is to create an Azure CLI Storage Account. To do so, run:

az storage account create --name $StorageAccountName --resource-group $ResourceGroup --location $Region --sku $StorageAccountSku --kind StorageV2
Storage-account-Created
Creating Storage Account
Note that Storage Account is a global resources on Azure. So the name must give a unique name that is not already in existence. If you the name has been taken already, you will receive an prompt while creating it.
Storage-account-name-taken
Storage Account Already exist

Step 3 – Enable static website hosting for your storage account

Before you can run a static website on your Azure Storage Account you must first of all enable the static website hosting feature for the blob storage. To do so, run:

az storage blob service-properties update --account-name $StorageAccountName --static-website --index-document index.html
Enabled-for-static-website-hosting
Enabling Storage Account for Static Website Hosting

To confirm that the storage account has been enabled for static website hosting and also that the $web container has been created when we created the storage account, let’s head to the Azure Portal to check.

When you’re in the Azure CLI Portal, locate and click on "Resource Groups"

Resource-Groups
Azure Portal

In the list of Resource Groups, the display locate the name of the Resource Group you created to hold your Resources and locate the storage account you created earlier. Here, the name of our Resource Group is webfilesRG while the storage account name is webfilestorage1

Resource-Group-and-Storage-Account
Resource Group and Storage Account on Azure Portal

At this point, double-click to open the storage account dashboard, locate and click on static website tab in the storage account blade to see that it has been enabled. In there, you will also find that the $web container has been created. Below the $web container is the primary endpoint. The primary endpoint is the URL that will be accessible to your website visitors.

Static-website-enabled-and-web-container-created
Static website enabled and $web container created

Step 4 – Upload website folders from the local path

To upload the website files, you will first of changing the working directory to the directory where your website files folder is located on your local PC with cd <DirectoryName> the command. Here is the folder container our website files is located on the Desktop of our local PC.

If you have changed the working directory, run:

az storage blob upload-batch --s $LocalPath --d '$web' --account-name $StorageAccountName
Files-Upload-in-Progress
File Upload in Progress

After the bulk files upload has been complete, your output screen should look like the below screenshot.

Upload-output
File Upload Output Screen

Now, head back to the $web container by clicking on the container tab under Data Storage in the storage account blade on the Azure CLI Portal to open it and assess your website files.

Web-files
Web files in the blob storage container

Step 5 – Display the website URL

To display the website URL, run:

az storage account show -n $StorageAccountName --resource-group $ResourceGroup --query "primaryEndpoints.web" --output tsv
az-account-show-URL
Displaying Website URL

The website URL is displayed as shown in the screenshot above. Visiting the URL will take visitors to the website page.

Website-displays
Website Page

You’re free to the customer the free template to reflect your information. As shown in the screenshot above, I have customized the information to reflect my information.

Clean up Azure Resources

To avoid being charged for resources running on your subscription in Azure CLI, delete the resources you have just created. To do so, we will delete the Resource Group that contains all the resources we have used for the exercise.

Run:

az group delete --resource-group <ResourceGroupName> 

When prompted "Are you sure you want to perform this operation? (y/n): type Y"

Delete-Resource-Group
Deleting Resource Group

Congrats! You’ve just learned how to create a Resource Group, an Azure storage account, enable a storage account for a static website, upload bulk files to an Azure blob storage container, and display the website URL using Azure CLI.

Be on the lookout for another insightful guide! I hope you found this blog post helpful. Please let me know in the comment session if you have any questions.

Rate this post

Thank you for reading this post. Kindly share it with others.

  • Share on X (Opens in new window) X
  • Share on Reddit (Opens in new window) Reddit
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on Facebook (Opens in new window) Facebook
  • Share on Pinterest (Opens in new window) Pinterest
  • Share on Tumblr (Opens in new window) Tumblr
  • Share on Telegram (Opens in new window) Telegram
  • Share on WhatsApp (Opens in new window) WhatsApp
  • Share on Mastodon (Opens in new window) Mastodon
  • Share on Bluesky (Opens in new window) Bluesky
  • Share on Threads (Opens in new window) Threads
  • Share on Nextdoor (Opens in new window) Nextdoor
AWS/Azure/OpenShift, Storage, Web Server Tags:Azure, Azure CLI, PowerShell, Website

Post navigation

Previous Post: How to Remove and Manage RDS Licenses
Next Post: How to Disable Internet Explorer with Group Policy & Registry

Related Posts

  • Continuous Deployment Pipeline Using AWS CodePipeline
    Setup a Continuous Deployment Pipeline with AWS CodePipeline AWS/Azure/OpenShift
  • Screenshot 2020 05 13 at 19.23.25
    AWS Command-Line Interface: How to configure AWS CLI [Part 1] AWS/Azure/OpenShift
  • hgjk
    Understanding the different types of Proxy Servers Web Server
  • IIS Installed
    Add and remove IIS Web Server on Windows Server 2019 via the Server Manager and PowerShell Web Server
  • Commvault Docker Images
    Pull and Push Commvault Images to Azure Container Registry AWS/Azure/OpenShift
  • image 26
    Add an EBS volume to AWS EC2 via the AWS Console and CLI AWS/Azure/OpenShift

More Related Articles

Continuous Deployment Pipeline Using AWS CodePipeline Setup a Continuous Deployment Pipeline with AWS CodePipeline AWS/Azure/OpenShift
Screenshot 2020 05 13 at 19.23.25 AWS Command-Line Interface: How to configure AWS CLI [Part 1] AWS/Azure/OpenShift
hgjk Understanding the different types of Proxy Servers Web Server
IIS Installed Add and remove IIS Web Server on Windows Server 2019 via the Server Manager and PowerShell Web Server
Commvault Docker Images Pull and Push Commvault Images to Azure Container Registry AWS/Azure/OpenShift
image 26 Add an EBS volume to AWS EC2 via the AWS Console and CLI AWS/Azure/OpenShift

Leave a Reply Cancel reply

You must be logged in to post a comment.

Microsoft MVP

VEEAMLEGEND

vexpert-badge-stars-5

Virtual Background

GoogleNews

Categories

veeaam100

Veeam Vanguard

  • djhfhjhg
    What is the difference between iDRAC, IPMI, and ILO Network | Monitoring
  • sshfs
    Mounting remote directory using sshfs Linux
  • scandium
    How to Test Web Applications Using Scandium Configuration Management Tool
  • Featured image BitLocker AES XTX 256
    Enable BitLocker AES-XTX 256 Encryption Security | Vulnerability Scans and Assessment
  • Screenshot 2022 03 21 at 18.06.30
    How to Configure Virtual Host for Apache HTTP Web Server to Host Several Domains on Ubuntu 20.04 LTS Linux
  • showdefenderupdate
    View Microsoft Defender Antivirus Update Details on Windows Image Windows
  • Featured image   The Local Device Name is Already in Use
    How to Fix The Local Device Name is Already in Use Windows
  • image 36
    Keepalive Settings: Understanding keepalive configuration Linux

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,821 other subscribers
  • RSS - Posts
  • RSS - Comments
  • About
  • Authors
  • Write for us
  • Advertise with us
  • General Terms and Conditions
  • Privacy policy
  • Feedly
  • Telegram
  • Youtube
  • Facebook
  • Instagram
  • LinkedIn
  • Tumblr
  • Pinterest
  • Twitter
  • mastodon

Tags

Active Directory Azure Bitlocker Microsoft Windows PowerShell WDS Windows 10 Windows 11 Windows Deployment Services Windows Server 2016

Copyright © 2025 TechDirectArchive

 

Loading Comments...
 

You must be logged in to post a comment.