Upgrading a Blazor WebAssembly Azure Static Web App from .NET 5 to .NET 6

In this post, I briefly discuss the process of upgrading a Blazor WebAssembly App from .NET 5 to .NET 6.

Dave Brock
Dave Brock

In the last year or so, I've been working on a Blazor WebAssembly project called Blast Off with Blazor. It's a Blazor WebAssembly app hosted on the Azure Static Web Apps service, which recently went GA. Right now, it consists of four small projects: an Azure Functions API project, a project for the Blazor WebAssembly bits, a project to share models between the two, and a test project.

I wanted to see how easily I could upgrade the Blazor project from .NET 5 to .NET 6. With .NET 6 now on Preview 4, it's evolved enough where I'm ready for an upgrade. I was hoping I could double-click the project file, change my client and test projects from net5.0 to net6.0, and be on my way. (I also know I was being very optimistic.)  

After upgrading the TFM, I was able to run the app successfully. Great. I started this app using .NET 5 and its mature API surface, so I didn't expect any issues there.  The interesting part is deploying it to Azure Static Web Apps. Azure Static Web Apps uses the Oryx build system and I wasn't too sure if it supported .NET 6 yet. It does, and it deployed to Azure Static Web Apps on the first try.

What about upgrading Azure Functions to .NET 6?

Recently, the Azure Functions team announced initial support of running Azure Functions on .NET 6. This currently requires running a preview release of Azure Functions Core Tools V4. So, I could get this working locally but the support won't come to Azure Static Web Apps until we get closer to .NET 6 GA in November 2021. I'll upgrade it then. For me, I'd rather upgrade the Blazor project so I can take advantage of things like hot reload, AOT, and JSON serialization improvements.

Azure Static Web AppsBlast Off With BlazorBlazorASP.NET CoreAzure