Scott Hanselman

Penny Pinching in the Cloud: Azure Static Web Apps are saving me money

March 04, 2021 Comment on this post [9] Posted in Azure
Sponsored By

I've long run a few dozen websites in Azure and while I've long noticed people (frankly) wasting money by having one Azure App Service (a Web Site) per Azure App Service Plan (a VM) I tend to pack them tight.

A Basic 1 (B1) Azure App Service running Linux is around $13 a month but has nearly 2 gigs of RAM. Up that to about $26 a month and you've got 3.5 gigs of RAM and 2 Cores AND 10 gigs of storage. Use ALL that RAM. Max out that storage - use the resources you have paid for. If you hit up against a limit you can always add more and scale up. Run those boxes hot, you paid for them!

While my blog and podcast and main site run on Azure Premium SKUs (and are fast and it's worth it) I have a dozen little one pagers, brochureware sites, and toys like https://www.keysleft.com/ and I've managed them all in an App Service as well. But they are static sites. They are nothing sites...so why do I need an App Service? It's overkill.

Turns out Azure Static Web Apps are a lovely thing and they are FREE while in Preview. It's great for static sites, sites made with static site generators, or Jamstack sites with serverless functions behind them.

So I converted a bunch of my little sites to Azure Static Web Apps. Took maybe 90 minutes to do 8 of them as seen below.

Azure Static Web Apps

Since the code for these sites was already in GitHub, it was very easy to move them.

For example, the code for the KeysLeft site is at https://github.com/shanselman/keysleft and Azure Static Web Apps has a GitHub Action that easily deploys it on every commit. It's butter. It's created for you but you can see the generated GitHub Action as it lives alongside your code.

Azure Static Web App Static Site

The docs are clear and it works nicely with Vue, React, Angular, or just regular HTML like my son's Hamster Blog. https://www.myhamsterblog.com/

As it's in Preview now it's free, and I'm sure it'll be super cheap when it goes live. I have no idea how much it will cost but I'll worry about that later. For now it's allowed me to turn off an entire Azure App Service and replace it with Azure Static Web Apps.

They also support custom domains and they automatically make and assign you an SSL cert. My only complaint is that there's no easy support (today) for apex domains (so all mine have www. as CNAMES) but you could proxy it through a free Cloud Flare account if you really want.

Check it out, I suspect you have a site right now that's either generated or just static and this could save you some money.


Sponsor: Protect your apps from reverse engineering and tampering with PreEmptive, the makers of Dotfuscator. Dotfuscator has been in-the-box with Microsoft Visual Studio since 2003. Visit preemptive.com/hanselminutes for a professional-grade trial.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
March 10, 2021 9:06
Honestly, I'm a big fan of them - they do a great job of replacing the Storage Account + CDN setup I've relied on for this stuff previously. Unfortunately I have to caveat that (for now) with another limitation: you can currently only have one custom domain associated with your static site (and CloudFlare proxying won't help you bypass that).
March 10, 2021 11:04
Why not use GitHub pages to host those kind of sites? Easy to set up, route the domain through Cloudflare for https and analytics and you are done. I'm hosting my company site on GH pages: More Than Code. It's a simple site, but gets the job done.
March 10, 2021 11:52
I'm relying on a read access geo redundant storage account + azure CDN routing rules to host my static sites.

This setup has the same benefits as app service static sites but also offers failover and still costs pennies. Sadly enough it also has the same downside: the lack of SSL support on the Apex Domain.

I never understood why Azure offers 2 ways to do the same thing, and what the differentiator is to choose app service static websites over storage static sites + CDN?

I've blogged about my setup here: https://www.goeleven.com/blog/cdn-hosting/
March 10, 2021 11:55
I'm really liking them too!
They are super easy to set up and as you've blogged before are great in combination with client-side Blazor and Azure functions. And getting a CI/CD pipeline set up in a few simple clicks still amazes me :)
Very interesting to see what the pricing will be, but as you say it should be really cheap.
March 10, 2021 16:45
Wish the web apps & app service plans were this economical. Finding the right mix of cpu/memory/storage that comes close to the value of a VM is impossible. Moved my two sites to web apps and I’m paying out the nose for it.
March 11, 2021 11:23
The biggest gem on this article is the link to your son's website! What an epic site! Although, it seems to be a bit outdated:
We got him in 2015.
March 11, 2021 22:05
The only downside is that you need to use Github.

Will this feature eventually support pushing code from Azure Devops?

I'm currently using that to generate a static site and upload to a storage account fronted by Cloudflare. Downside is less control of headers/etc. that an App Service provides.
March 12, 2021 10:27
Is good that services like this are not expensive. The only thing is that cloud services sometimes aren't the safest around, but is a good option. Thanks for sharing.
March 12, 2021 11:22
I tried Azure Static Web Apps, but I moved to free tier App Service. Because of Azure static Web Apps can't handle basic authentication.
Anyway, I have a super lightweight Asp.Net Core 5 webapp (100 hundred lines :) ), which solves basic auth, and it is as fast as static pages. And free.

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.