aspire_skill
- C#
0
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill stuartf303/sorcha --skill aspire- SKILL.md4.4 KB
Overview
This skill configures .NET Aspire orchestration, service discovery, and telemetry for microservices running under the AppHost. It shows how to register database and cache resources, add services to the host, and apply consistent defaults like OpenTelemetry, health checks, and shared configuration values such as JWT signing keys.
How this skill works
AppHost centralises service registration by declaring resource objects (Postgres, MongoDB, Redis) and adding projects with WithReference and WithEnvironment to wire discovery and shared configuration. Each service bootstraps with builder.AddServiceDefaults(), which registers OpenTelemetry, health endpoints, and discovery integrations so services can locate resources by resource name. Health and liveness endpoints are mapped automatically and resource references inject connection strings or URLs into service environments.
When to use it
- When adding a new microservice to the AppHost and wiring its dependencies.
- When standardising OpenTelemetry, health checks, and discovery across services.
- When configuring databases, caches, or external endpoints for multiple services.
- When sharing secrets or common settings (e.g., JWT signing key) across services.
- When troubleshooting service discovery or health checks in a local or orchestrated environment.
Best practices
- Declare shared resources once in AppHost and reference them with semantic resource names.
- Use WithEnvironment to inject secrets and non-sensitive config via environment variables consistently.
- Start every service with builder.AddServiceDefaults() to ensure uniform telemetry and health behavior.
- Tag health checks for liveness vs readiness and expose both /alive and /health endpoints.
- Prefer resource references (.WithReference) over hard-coded connection strings to keep services portable.
Example use cases
- Add a new API service: register it in AppHost, WithReference(postgres) and WithReference(redis), then call AddServiceDefaults in the service Program.cs.
- Create multi-database Postgres resources: define a postgres resource and call AddDatabase for tenant and wallet DBs to produce distinct connection strings.
- Enable shared JWT signing: generate the signing key once in AppHost and pass it to services with WithEnvironment("JwtSettings__SigningKey", key).
- Expose an internal service externally: use WithExternalHttpEndpoints() for a service that must be reachable outside the Aspire network.
- Troubleshoot discovery issues: verify resource names used in WithReference match the declared resource identifiers and check /health for failing checks.
FAQ
Yes. AddServiceDefaults registers observability, discovery, and health checks consistently; skipping it will require you to configure those concerns manually.
How are connection strings shared with services?
AppHost injects connection strings and endpoint URLs via WithReference and WithEnvironment, exposing values as environment variables inside each service.