.Net, Azure and occasionally gamedev

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") is limited to 10 webapps per instance and costs 30€/month.

Technically you can have more than 10 web apps per instance by (ab)using the 4 additional (free) slots that are intended for staging and swapping with production.

So, at the very most you can get: 10 web apps * (4 slots + 1 production slot) = 50 web apps out of a single Standard app service instance.

However, you will run into memory problems way before you actually have 50 apps running because each slot will have some overhead with the w3wp process running even if it's just a single static html file. (I'm nowhere near 50 web apps and I'm already at ~60% constant RAM usage).

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 and Webapps