aspire-service-defaults

Create a shared ServiceDefaults project centralizing OpenTelemetry, health checks, and resilience for Aspire applications.

Updated Mar 8, 2026
One-click install
npx skills add https://github.com/AGIBuild/dotnet.CI.template --skill aspire-service-defaults-agibuild
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: aspire-service-defaults
Source: https://github.com/AGIBuild/dotnet.CI.template/tree/main/.cursor/skills/aspire-service-defaults
Command: npx skills add https://github.com/AGIBuild/dotnet.CI.template --skill aspire-service-defaults-agibuild

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Aspire-based distributed applications require every service to configure OpenTelemetry, health checks, service discovery, and HTTP resilience consistently, and duplicating this setup across services leads to drift and misconfiguration. ## Core Features & Use Cases - Shared ServiceDefaults Project: Centralizes OpenTelemetry logging, metrics, and tracing, health checks, service discovery, and HttpClient resilience in one project referenced by all services. - Health Check Endpoints: Maps readiness and liveness endpoints with tag-based filtering and guidance for production hardening. - Extensibility Patterns: Shows how to add custom health checks (PostgreSQL, Redis), custom trace sources (Akka.NET, domain ActivitySources), and OTLP exporter integration with the Aspire Dashboard. - Use Case: When scaffolding a new Aspire solution with an API, a worker, and an AppHost, use this Skill to generate the ServiceDefaults project and wire AddServiceDefaults() into every service for uniform observability. ## Quick Start Create an Aspire ServiceDefaults project with OpenTelemetry, health checks, and service discovery, and show me how to call AddServiceDefaults from my API and worker services.

Frequently Asked Questions about aspire-service-defaults

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a ServiceDefaults project for Aspire?▼

Create a class library targeting net9.0 with IsAspireSharedProject set to true, reference the OpenTelemetry, ServiceDiscovery, and Http.Resilience packages, then expose an AddServiceDefaults extension method that every service calls in Program.cs.

How do I add health checks to an Aspire service?▼

Register checks with AddHealthChecks in AddDefaultHealthChecks, tagging liveness checks as live, then map /health and /alive endpoints via MapDefaultEndpoints. You can add NpgSql, Redis, or custom checks tagged as ready for readiness probes.

Does ServiceDefaults work with non-web worker services?▼

Yes, AddServiceDefaults works with any IHostApplicationBuilder, including Host.CreateApplicationBuilder for worker services. Only MapDefaultEndpoints requires a WebApplication since it maps HTTP health endpoints.

How does OpenTelemetry export to the Aspire Dashboard?▼

The AppHost automatically sets the OTEL_EXPORTER_OTLP_ENDPOINT environment variable for each service. When ServiceDefaults detects this configuration, it registers the OTLP exporter, sending traces, metrics, and logs to the Aspire Dashboard.

Should health check endpoints be exposed in production?▼

The default template only maps health endpoints in development. For production, map them explicitly with minimal plain-text responses, and consider internal-only ports, authorization, or rate limiting to avoid leaking diagnostic details.