Today, in this post, I want to show you how to use Azure PowerShell to create a static website in Azure Storage GPv2 accounts. This interesting functionality allows us to publish a static website without any additional cost, only the storage used.

This tutorial assumes that you already have a Microsoft Azure account set up.

Important: This feature is available only for Azure Storage GPv2 accounts.

Azure PowerShell Workaround

If you want to know how to install the PowerShell Azure module on your machine, check out this link.

The simplest way to get started is to sign in interactively at the command line.

This cmdlet will bring up a dialog box prompting you for your email address and password associated with your Azure account.
If you have more than one subscription associated with your mail account, you can choose the default subscription. To perform this task we will use the following commands:

Once you set your default subscription, you’re ready to start.

Set the variables

Here, we define the characteristics of our environment.

Resource Group

With the following command in PowerShell, we obtain the list of existing resource groups in your subscription.


If you need to create a new resource group, check out this link.


With the following cmdlet in PowerShell, we obtain the list of existing locations in Azure.


Storage Account

To create a Storage Account with PowerShell, use the New-AzStorageAccount cmdlet with the following syntax:

Enable the static website feature

Once the GPv2 storage account is created, you can enable the static website character using the Enable-AzStorageStaticWebsite cmdlet with the following syntax:

The file indicated in the -ErrorDocument404Path parameter will be displayed when a browser requests a page that does not exist.


When you enable a static website on your storage account, a container named $web is created.

Upload the website files to the blob storage container

Upload your web files to the $web container using the following commands:


Access to the Static Website

With the following command, you can see the primary endpoints of your storage account. in this case, you should use the “Web” endpoint.


Finally,Open the Storage static website endpoint URL in a web browser to view the Website.

Azure Static Website

To make your static website files available over your custom domain and HTTPS, check out this link: