Project Plan: Blazor WebAPI server, Blazor Web client, MSSQL database - All in Docker
Tags: docker, dotnetcore, microservices, sqlserver
Published: 2023-03-02 05:08:18

**Introduction**

This article series will detail my experience dockerizing a "mostly internal" legacy Windows application with a SQL Server backend (more on the legacy application being "dockerized" in [part 2](https://dev.to/prill/the-legacy-application-i-plan-to-dockerize-part-2-25fo)). To decouple my application, I will be leveraging microservices and tie them together with an API. Envoy will be used as a proxy to handle incoming requests to the gateway.

** Application Architecture **

The new application will be brokend down like so:

- An ASP.net Core Blazor Server WebAPI project that will have the necessary endpoints to be the "gateway" to the back-end database.
- I will utilize Entity Framework in this project and a "database-first" approach since this application has an existing database schema. Once I generate the initial Models I need, I may transition to a code-first/migrations model to create a new database with a cleaned-up schema (then later copy over the data from the legacy database).
- The database is currently a SQL Server database hosted on-premise on a VM with an old Windows Server OS that Corporate It wants me to decomission - this is the main motivation for this project.
- My goal is to host the Blazor WebAPI and SQL Server database in separate Docker containers from the "get go" (that is, during development Visual Studio will launch the WebAPI project in a docker container and attach the database into a separate docker container with a persistent volume).
- Once I get the API methods coded and tested with Swagger, I'll move onto creating a client front-end that will also be in Blazor, but it will be a Blazor Webassembly (client) project.
- The web client may or may not be hosted in docker during development, but once it is ready for deployment it will most likely be.

Well, for an "old dog" like me that project plan is agressive, but keep checking back to see how it goes. I'm sure we'll all learn something along the way!

Next, for more on the legacy application I'm dockerizing, [check out part 2](https://dev.to/prill/the-legacy-application-i-plan-to-dockerize-part-2-25fo).

**Helpful links**

The following links are references to videos/articles I have found that I may refer back to while completing this project (keeping for my own reference).

[Blazor Webapp Tutorial Playlist - Beginner to Advanced](https://www.youtube.com/watch?v=dY_AWdCzsCY&list=PLzewa6pjbr3IQEUfNiK2SROQC1NuKl6PV)
- Above summary copied from this video
- Get started with front-end development in Blazor

[Video: .Net Core App with SQL Server](https://www.youtube.com/watch?v=hpLvXNASyTI) 
- App and DB running in separate containers
- How to deploy with Docker-Compose

[Video: Simple .Net Microservice with SQL Backend](https://www.youtube.com/watch?v=2p01iafOxUw)
- Uses SQL Server Entity Core Framework
- Tests Api with Postman
- Deploys with Docker Compose

[Video: ASP.Net Core API Gateway with Ocelot](https://www.youtube.com/watch?v=k4l3Ptd4yjw)
- Ties all the microservices together in short video
- Separate series linked on creating front-end Blazor app
- Uses Ocelot which is now dormant project
    - Envoy is the "new option" (see next video)

[Video: Build an API Gateway with Envoy and use with .NET Core APIs](https://www.youtube.com/watch?v=UsoH5cqE1OA)
- Long video but explains entire architecture in detail
- Dives into using Envoy as the proxy for the APIs
- Video description links to other videos relevant to the topic
- Ingredients used:
    - VS Code
    - .Net Core SDK
    - Testing with Postman / Curl / Browser
    - OpenSSL (for Envoy HTTPS components)

[Install Docker on Windows Server 2019](https://4sysops.com/archives/install-docker-on-windows-server-2019/)
- If you choose to deploy to an internal server/vm that server will need to have Docker/containter orchestration capabilities.
- The above link discusses installing Docker on a Windows 2019 server/vm.

--