Penny Pinching in the Cloud: Azure Static Web Apps are saving me money
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.
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.
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.
About Newsletter
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/
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.
We got him in 2015.
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.
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.