Running the solution with .NET Aspire
In Chapter 2, we added .NET Aspire to the solution, which contained only the games API service. In Chapter 3, we added a SQL Server database running in a Docker container without keeping state. Here, we’ll extend the .NET Aspire configuration by using SQL Server running in a Docker container using a volume and configure the bot service to access the games API.
Configuring a Docker container for SQL Server
Using a Docker container with .NET Aspire can be orchestrated using .NET code – with extension methods of the IDistributedApplication
interface:
Codebreaker.AppHost/Program.cs
var builder = DistributedApplication.CreateBuilder(args); var sqlPassword = builder.AddParameter("SqlPassword", secret: true); var sqlServer = builder.AddSqlServer("sql", sqlPassword) WithDataVolume("codebreaker-sql-data", isReadOnly: false) .AddDatabase("CodebreakerSql"); var gameAPIs...