liveBook · Manning

Service defaults

As explained in Building Distributed Applications that Work

Service defaults are reusable Aspire startup conventions and settings that provide common capabilities to application services.

Service defaults are a shared class library of startup extension methods for Aspire applications. They provide common capabilities such as service discovery, health assessment, metrics collection, and other shared functionality. The library can be modified to fit an application's needs, including replacing its metrics or health-check mechanisms. section 1.8

To use service defaults in an ASP.NET Core service:

  • Reference the Service Defaults project and call AddServiceDefaults() during the builder phase. section 10.2
  • Call MapDefaultEndpoints() in the request pipeline to expose health-check and other shared endpoints. section 10.2
  • The class library needs the Microsoft.AspNetCore.App framework reference and packages for the capabilities it uses. section 1.8
builder.AddServiceDefaults();

Startup registration adds the shared Aspire dependencies to a service. section 10.2

app.MapDefaultEndpoints();

Pipeline registration exposes the shared endpoints, including health checks. section 10.2

How Building Distributed Applications that Work covers it

How deep it goes
Defines the shared extension-method library and shows startup integration, but does not detail capability implementations.
Examples
Uses OnlineShop.ServiceDefaults and an existing Blazor frontend with a backend API to illustrate shared defaults and enrollment.
What it assumes
Requires ASP.NET Core hosting types and package references for the selected capabilities.
What you can do after
Apply shared service discovery, health checks, and telemetry by referencing the library and adding its startup extensions.
How it connects
Connects Aspire orchestration with service discovery, health checks, and telemetry.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Distributed Applications that Work. The section links point to the parts of the book it draws on.