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
  • group policy 1280x720 1
    Error: The processing of Group Policy failed because of lack of network connectivity to a DC. This may be a transient condition. A success message would be generated once the machine gets connected Windows Server
  • NTUSER Files in Windows
    What Is the NTUSER.DAT File in Windows? Windows
  • Leave Slack
    How to remove a user from a Slack Channel JIRA|Confluence|Apps
  • maxresdefault 2 1
    How to disconnect a Remote Desktop User Windows Server
  • understanding azure active directory and enterprise mobility security ems 16 638
    Methods for Integrating Azure Active Directory with on-Premise Active Directory AWS/Azure/OpenShift
  • AADSTS900144
    Fix AADSTS900144: The request body must contain the parameter Network | Monitoring
  • settings app not working featured 800x400 1
    How to save and stop modification to Microsoft Management Console Windows
  • VMware Aria
    VMSA-2022-0026: An arbitrary file read vulnerability in VMware Aria Operations Security | Vulnerability Scans and Assessment

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.

  • Click to share on X (Opens in new window) X
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on Bluesky (Opens in new window) Bluesky
  • Click to share on Threads (Opens in new window) Threads
  • Click to 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

  • s3versioning
    Hosting Static Website and Versioning on AWS S3 AWS/Azure/OpenShift
  • DS923   what is taking up my space
    What is taking up by Synology NAS Volume Space Storage
  • insufficientaccessright 1
    Azure AD Connect Permission issue: Error 8344 insufficient access rights to perform the operation AWS/Azure/OpenShift
  • images
    AWS Network Adapter: Redhat to Citrix PV and AWS PV Driver AWS/Azure/OpenShift
  • Installing Jenkins
    How to Install and Configure Jenkins on Windows 11 Configuration Management Tool
  • Webp.net resizeimage 3 1
    How To Configure VM Update Management on Azure Stack Hub AWS/Azure/OpenShift

More Related Articles

s3versioning Hosting Static Website and Versioning on AWS S3 AWS/Azure/OpenShift
DS923   what is taking up my space What is taking up by Synology NAS Volume Space Storage
insufficientaccessright 1 Azure AD Connect Permission issue: Error 8344 insufficient access rights to perform the operation AWS/Azure/OpenShift
images AWS Network Adapter: Redhat to Citrix PV and AWS PV Driver AWS/Azure/OpenShift
Installing Jenkins How to Install and Configure Jenkins on Windows 11 Configuration Management Tool
Webp.net resizeimage 3 1 How To Configure VM Update Management on Azure Stack Hub 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

sysadmin top30a

  • group policy 1280x720 1
    Error: The processing of Group Policy failed because of lack of network connectivity to a DC. This may be a transient condition. A success message would be generated once the machine gets connected Windows Server
  • NTUSER Files in Windows
    What Is the NTUSER.DAT File in Windows? Windows
  • Leave Slack
    How to remove a user from a Slack Channel JIRA|Confluence|Apps
  • maxresdefault 2 1
    How to disconnect a Remote Desktop User Windows Server
  • understanding azure active directory and enterprise mobility security ems 16 638
    Methods for Integrating Azure Active Directory with on-Premise Active Directory AWS/Azure/OpenShift
  • AADSTS900144
    Fix AADSTS900144: The request body must contain the parameter Network | Monitoring
  • settings app not working featured 800x400 1
    How to save and stop modification to Microsoft Management Console Windows
  • VMware Aria
    VMSA-2022-0026: An arbitrary file read vulnerability in VMware Aria Operations Security | Vulnerability Scans and Assessment

Subscribe to Blog via Email

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

Join 1,836 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 AWS Azure Bitlocker Microsoft Windows PowerShell WDS Windows 10 Windows 11 Windows Server 2016

Copyright © 2025 TechDirectArchive

 

Loading Comments...
 

You must be logged in to post a comment.