Hosting a Containerized Client Side Blazor Application On Azure
Its not a secret by now that Blazor is taking the .Net Core world by storm. I won’t go into the details of what Blazor is or how the different hosting models work as its been widely discussed in the community. For a quick reference of Blazor overview as well as the different hosting models you can check the Microsoft docs located here and here, respectively. In this post I will mainly focus on hosting a containerized WebAssembly Blazor application on Azure. I will use Azure DevOps to build a CI/CD pipeline which will deploy the Docker image that contains our Blazor application. I will also utilize Azure Container Registry (ACR) to store the Docker images. And finally I will use Azure App Service to run the Docker image which will serve our application.
Source code can be found here.
Start by installing the latest .Net Core Previews SDK which you can find here. Once you have the SDK installed you can either use Visual Studio or the dotnet CLI as discussed here.
Start by creating a a new Blazor application using Visual Studio 2019 (you can also use the dotnet CLI) as shown below. Notice that the “Enable Docker Support” checkbox is disabled for the WebAssembly option, so we will manually add the Dockerfile later on.
Note: I imagine this checkbox will be enabled sometime in the future