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
  • Angular 1
    How to deploy an Angular App to AWS S3 AWS/Azure/OpenShift
  • ext
    The DriveLock server returned an invalid or unrecognized response Security | Vulnerability Scans and Assessment
  • Reset folder view settings on File Explorer for Windows 11 and 10
    Reset folder view settings on File Explorer for Windows 11 and 10 Windows
  • How to fix BitLocker always prompting for Recovery Key
    How to fix BitLocker always prompting for Recovery Key Windows
  • screenshot 2020 03 15 at 00.43.16
    How to permit and run only certain apps in windows Windows
  • sandbox
    How to Configure Windows Sandbox Virtualization
  • Windows Productivity Tips
    Windows Productivity Tips To Get The Most Out Of Your PC Windows
  • VBR upgrade to 12.3.1
    Upgrade VBR to 12.3.1: Setup detected inconsistent configuration Backup

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

  • Uninstall Wampserver
    How to uninstall WAMPServer from Windows Web Server
  • Webp.net resizeimage 5
    How to Improve Website Response Using Traffic Manager AWS/Azure/OpenShift
  • Webp.net resizeimage 4
    Create, list, lock, deploy, and delete Azure Resource Group via Azure CLI AWS/Azure/OpenShift
  • Webp.net resizeimage 3 1
    How To Configure VM Update Management on Azure Stack Hub AWS/Azure/OpenShift
  • AZMFeature
    Performance and Diagnostics in Microsoft Cloud with Azure Monitor AWS/Azure/OpenShift
  • Syncing Files  and photos with Synology Drive
    Sync file and photos from iOS and Mac with Synology Drive Backup

More Related Articles

Uninstall Wampserver How to uninstall WAMPServer from Windows Web Server
Webp.net resizeimage 5 How to Improve Website Response Using Traffic Manager AWS/Azure/OpenShift
Webp.net resizeimage 4 Create, list, lock, deploy, and delete Azure Resource Group via Azure CLI AWS/Azure/OpenShift
Webp.net resizeimage 3 1 How To Configure VM Update Management on Azure Stack Hub AWS/Azure/OpenShift
AZMFeature Performance and Diagnostics in Microsoft Cloud with Azure Monitor AWS/Azure/OpenShift
Syncing Files  and photos with Synology Drive Sync file and photos from iOS and Mac with Synology Drive Backup

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

  • Angular 1
    How to deploy an Angular App to AWS S3 AWS/Azure/OpenShift
  • ext
    The DriveLock server returned an invalid or unrecognized response Security | Vulnerability Scans and Assessment
  • Reset folder view settings on File Explorer for Windows 11 and 10
    Reset folder view settings on File Explorer for Windows 11 and 10 Windows
  • How to fix BitLocker always prompting for Recovery Key
    How to fix BitLocker always prompting for Recovery Key Windows
  • screenshot 2020 03 15 at 00.43.16
    How to permit and run only certain apps in windows Windows
  • sandbox
    How to Configure Windows Sandbox Virtualization
  • Windows Productivity Tips
    Windows Productivity Tips To Get The Most Out Of Your PC Windows
  • VBR upgrade to 12.3.1
    Upgrade VBR to 12.3.1: Setup detected inconsistent configuration Backup

Subscribe to Blog via Email

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

Join 1,841 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

AWS 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.