C#, .Net and Azure

Cheap static websites using azure storage

2018/09/09

There’s a new preview to enable static websites in storage accounts.

With the static website preview you can host all your static websites using storage accounts and don’t need to use web app (slots) for them!

The only costs will be the default storage pricing:

Storage runs at 0.0166€/GB/month for LRS or 0.0414€/GB/month for RA GRS. On top of that you pay 0.0911€ per 10k writes, so even if you continuously deploy from your devops pipeline you don’t really have to worry about these costs.

Comparison to app services

An app service of size “Standard” (first size that allows custom domains and “always on”) costs 60€/month.

Technically you can deploy unlimited apps to it but with each w3wp process using some memory you will run out of memory after less than a dozen apps even if they don’t really have much traffic.

Getting started

First create a storage account (must be v2, if you have an older storage account, fear not: there is an upgrade button in Azure!).

Once you have the storage account, click on “static websites (preview)” inside the storage account settings blade and enable it.

Once enabled it will show the url at which your site will be reachable (currently it is not really pretty. I would expect that this will eventually change to something similar like *.azurewebsites.net).

The only settings you have to specify are the default file that it should load (index.html makes sense) and the path to the 404 file.

Don’t forget to save the changes!

Settings

After enabling it the url is displayed and a new container “$web” will exist. All you have to do, is to upload your website to the “$web” container.

Here’s a static website that’s up and running in azure storage:

Hello world

All the expected stuff just works with storage account (navigation between pages, loading css, javascript, images, ..) and any changes after uploading new files are instant.

Custom domains and https

The storage account url supports http and https by default (you can even disable http by setting “Secure transfer required” to enabled).

Storage accounts also support custom domains for the static website but unfortunately not with https right now. To use https you need to use Azure CDN which impairs additional costs.

I would expect that such features will be added in the near future to make this a super easy way to host static content conveniently (such as public wikis akin to VSTS wikis or documentation similar to github pages).

tagged as Azure, App Service,