Aspirification is the process of enrolling existing applications in Aspire orchestration. An aspirified system keeps its application projects while adding an Aspire host to describe how they run together. For example, a hosted Blazor frontend can call a backend API that still reaches SQL Server through its existing connection string. section 10.2 section 10.6
Enroll an existing .NET solution incrementally:
- Add an Aspire host and, usually, a Service Defaults project. Use an IDE to add them manually, or run `aspire init` in the solution folder and follow its setup prompts. section 10.2
- Reference the existing projects from the host, then add them to `AppHost.cs`. Give the frontend a reference to the API and make it wait for the API when starting. section 10.2
- Reference Service Defaults from each participating service and call `builder.AddServiceDefaults()` during startup. Map default endpoints with `app.MapDefaultEndpoints()`; a host can use `/health` as an HTTP health check. section 10.2
Service Defaults is optional if the system already has its own metrics and health-check mechanisms, but it provides service discovery, telemetry, and health-check capabilities. Aspirification also need not move an external database into Aspire: existing connection strings can remain in place so the applications continue to use their production resources. section 10.2 section 10.6
Listing 10.5 Adding project references to the Aspire host
var builder = DistributedApplication.CreateBuilder(args);
var apiService = builder.AddProject<Projects.OnlineShop_ApiService>("apiservice")
.WaitFor
.WithReference;
builder
.AddProject<Projects.OnlineShop_Web>("webfrontend")
.WithExternalHttpEndpoints()
.WithReference(apiService)
.WaitFor(apiService);
builder.Build().Run();
The AppHost listing shows the existing API and frontend registered as projects, with the frontend referencing and waiting for the API. section 10.2
