![]() |
VOOZH | about |
dotnet add package Momentum.ServiceDefaults --version 0.0.12
NuGet\Install-Package Momentum.ServiceDefaults -Version 0.0.12
<PackageReference Include="Momentum.ServiceDefaults" Version="0.0.12" />
<PackageVersion Include="Momentum.ServiceDefaults" Version="0.0.12" />Directory.Packages.props
<PackageReference Include="Momentum.ServiceDefaults" />Project file
paket add Momentum.ServiceDefaults --version 0.0.12
#r "nuget: Momentum.ServiceDefaults, 0.0.12"
#:package Momentum.ServiceDefaults@0.0.12
#addin nuget:?package=Momentum.ServiceDefaults&version=0.0.12Install as a Cake Addin
#tool nuget:?package=Momentum.ServiceDefaults&version=0.0.12Install as a Cake Tool
Service defaults for Momentum apps providing common configurations for Aspire-based services including Kafka, PostgreSQL, OpenTelemetry, Serilog, resilience patterns, and service discovery. Essential for all Momentum host projects.
The Momentum.ServiceDefaults package provides a comprehensive set of default configurations for .NET Aspire-based services. It establishes consistent patterns for observability, messaging, data access, resilience, and service discovery across all Momentum applications.
Add the package to your project using the .NET CLI:
dotnet add package Momentum.ServiceDefaults
Or using the Package Manager Console:
Install-Package Momentum.ServiceDefaults
Microsoft.AspNetCore.App framework reference)// Program.cs
var builder = WebApplication.CreateBuilder(args);
// Add service defaults - configures all common services
builder.AddServiceDefaults();
// Add your application-specific services
builder.Services.AddScoped<IUserService, UserService>();
var app = builder.Build();
// Map default endpoints (health checks, metrics, etc.)
app.MapDefaultEndpoints();
// Add your application routes
app.MapGet("/api/users", (IUserService userService) =>
userService.GetUsersAsync());
app.Run();
// Program.cs
var builder = Host.CreateApplicationBuilder(args);
// Add service defaults for background services
builder.AddServiceDefaults();
// Add your worker services
builder.Services.AddHostedService<OrderProcessingWorker>();
var host = builder.Build();
await host.RunAsync();
When you call AddServiceDefaults(), the following services are automatically configured:
/status (liveness), /health/internal (readiness), /health (public)// Automatically available endpoints:
// GET /status - Liveness probe (cached, fast)
// GET /health/internal - Readiness probe (localhost only)
// GET /health - Public health (requires auth, detailed)
// Configuration includes:
// - ASP.NET Core instrumentation
// - HTTP client instrumentation
// - Runtime metrics
// - GrPC client instrumentation
// - OTLP exporter for telemetry data
// Logging configuration:
// - Structured JSON output
// - Exception details with Serilog.Exceptions
// - Correlation IDs and trace context
Configure your services using standard connection string patterns:
// appsettings.json
{
"ConnectionStrings": {
"Database": "Host=localhost;Database=myapp;Username=postgres;Password=password",
"Messaging": "localhost:9092"
}
}
Control observability settings:
// appsettings.json
{
"OpenTelemetry": {
"ServiceName": "MyApp",
"ServiceVersion": "1.0.0",
"Endpoint": "http://localhost:4317"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"System": "Warning"
}
}
}
Add application-specific health checks:
var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();
// Add custom health checks
builder.Services.AddHealthChecks()
.AddCheck<ExternalApiHealthCheck>("external-api")
.AddCheck<CacheHealthCheck>("redis-cache");
Extend OpenTelemetry configuration:
var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();
// Add custom telemetry
builder.Services.Configure<OpenTelemetryOptions>(options =>
{
options.AddSource("MyApp.CustomActivities");
});
Configure messaging with WolverineFx:
var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();
// WolverineFx is automatically configured with PostgreSQL persistence
// Add your message handlers
builder.Services.AddScoped<OrderCreatedHandler>();
builder.Services.AddScoped<PaymentProcessedHandler>();
var app = builder.Build();
app.MapDefaultEndpoints();
app.Run();
Customize HTTP resilience:
var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();
// Customize resilience for specific HTTP clients
builder.Services.AddHttpClient<ExternalApiClient>(client =>
{
client.BaseAddress = new Uri("https://api.external.com");
})
.AddResilienceHandler("external-api", static builder =>
{
builder.AddRetry(new RetryStrategyOptions
{
MaxRetryAttempts = 3,
BackoffType = DelayBackoffType.Exponential
});
});
// appsettings.Development.json
{
"ConnectionStrings": {
"Database": "Host=localhost;Database=myapp_dev;Username=postgres;Password=dev123"
},
"OpenTelemetry": {
"Endpoint": "http://localhost:4317"
},
"Logging": {
"LogLevel": {
"Default": "Debug"
}
}
}
// appsettings.Production.json
{
"ConnectionStrings": {
"Database": "Host=prod-db;Database=myapp;Username=app_user;Password=${DB_PASSWORD}"
},
"OpenTelemetry": {
"Endpoint": "https://telemetry.company.com"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning"
}
}
}
This package includes comprehensive integrations with:
| Package | Purpose |
|---|---|
| Aspire.Npgsql | PostgreSQL database connectivity |
| CloudNative.CloudEvents.SystemTextJson | CloudEvents specification support |
| FluentValidation.DependencyInjectionExtensions | Validation framework integration |
| Microsoft.Extensions.Http.Resilience | HTTP client resilience patterns |
| Microsoft.Extensions.ServiceDiscovery | Service discovery capabilities |
| OpenTelemetry Suite | Complete observability stack |
| Serilog.AspNetCore | Structured logging with ASP.NET Core |
| Serilog.Exceptions | Enhanced exception logging |
| Serilog.Sinks.OpenTelemetry | OpenTelemetry sink for Serilog |
| WolverineFx | Messaging infrastructure |
| WolverineFx.Postgresql | PostgreSQL integration for messaging |
This package is essential for:
This project is licensed under the MIT License. See the LICENSE file for details.
For contribution guidelines and more information about the Momentum platform, visit the main repository.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 2 NuGet packages that depend on Momentum.ServiceDefaults:
| Package | Downloads |
|---|---|
|
Momentum.Extensions.Messaging.Kafka
Kafka messaging integration for Momentum platform providing event-driven communication through Apache Kafka with CloudEvents and WolverineFx support. |
|
|
Momentum.ServiceDefaults.Api
API-specific service defaults for Momentum platform extending the base ServiceDefaults with gRPC, OpenAPI documentation (Scalar), and API-focused configurations. Essential for Momentum API projects. |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.0.12 | 69 | 6/11/2026 |
| 0.0.12-preview.9 | 50 | 6/11/2026 |
| 0.0.12-preview.8 | 49 | 6/11/2026 |
| 0.0.12-preview.7 | 51 | 6/11/2026 |
| 0.0.12-preview.6 | 58 | 6/11/2026 |
| 0.0.12-preview.5 | 68 | 5/27/2026 |
| 0.0.12-preview.4 | 65 | 5/21/2026 |
| 0.0.12-preview.3 | 61 | 5/20/2026 |
| 0.0.12-preview.2 | 66 | 5/14/2026 |
| 0.0.12-preview.1 | 67 | 5/12/2026 |
| 0.0.11 | 150 | 5/10/2026 |
| 0.0.11-preview.2 | 63 | 5/10/2026 |
| 0.0.11-preview.1 | 64 | 5/1/2026 |
| 0.0.10 | 97 | 5/1/2026 |
| 0.0.10-preview.8 | 56 | 5/1/2026 |
| 0.0.10-preview.7 | 56 | 5/1/2026 |
| 0.0.10-preview.6 | 66 | 4/28/2026 |
| 0.0.10-preview.5 | 61 | 4/24/2026 |
| 0.0.10-preview.4 | 62 | 4/24/2026 |
| 0.0.10-preview.3 | 62 | 4/22/2026 |