Azure – Host a static website in a storage account using Azure PowerShell.

What is a static website?

By the definition, the static website contains web pages with fixed content and displays the same content to every user on every visit, and static websites are very basic and easy to create.

Now static websites can be built using HTML, CSS and JavaScript and hosted on Azure Storage, and support client-side script execution but not server-side, if the static website needs some data processing or manipulation on server-side you can leverage it to Azure Cognitive Services or Azure Functions.

What is the use?

Static websites are very useful when it doesn’t require high bandwidth, backend support and targeted to limited audiences and mostly for the shorter duration of time.

Some useful areas are…

  • Explain about the project and the roadmap.
    • Just for the sake of presentation in the meeting, create some html documents with the necessary content, upload them to the Azure blob storage and simply access the url from anywhere in the world.
  • Showcase about the products, events and promotions.
    • Sales and marketing teams require nice and colorful web pages to walk through the concepts, so build a website using CSS & HTML, publish it on to Azure blob storage and share the link with the intended audience.
  • Technical Documents & Manuals
    • Host some technical documentation and manuals relating to your project, and share it with the team across the globe for their perusal.

How it works?

When the static website service is enabled on a Azure storage account you need to enter the default document name; and error document name as optional and when the feature is enabled a container named $web will be created if it doesn’t already exist to upload your website files. Files in the $web container are read only, case sensitive and available to access anonymously

How to access?

Available to the public web following this pattern:
https://<ACCOUNT_NAME&gt;.<ZONE_NAME>.web.core.windows.net/<FILE_NAME>

Available through a Blob storage endpoint following this pattern:
https://<ACCOUNT_NAME&gt;.blob.core.windows.net/$web/<FILE_NAME>

It can also available with CDN and SSL support and custom domain name as well.

What is the pricing?

Azure Static website feature is free; the pricing is only for storage. But in addition to the storage costs, data egress will apply and in case Azure CDN is enabled to use a custom domain with an SSL certificate, that will also be applicable.

How to enable the Static Website feature and host a website using Azure PowerShell?

All you need is a valid Azure subscription and follow the steps (in PowerShell)…

  • Login into Azure account.
  • Select the required subscription.
  • Select/Create a Resource Group.
  • Select /Create a Storage Account (StorageV2).
  • Set the current storage account to enable the Static Website feature.
  • Enable the Static Website feature on the current storage account.
  • Upload the website files to the blob storage container ($web).
  • Verify the files uploaded successfully.
  • Retrieve the URL to access the static website.

With the glory of GitHub public repositories, I have cloned a simple website and created my profile page just like that and hosted it on my Azure Storage.

capture