eShop.ServiceDefaults.Depi
1.0.1-beta.2
dotnet add package eShop.ServiceDefaults.Depi --version 1.0.1-beta.2
NuGet\Install-Package eShop.ServiceDefaults.Depi -Version 1.0.1-beta.2
<PackageReference Include="eShop.ServiceDefaults.Depi" Version="1.0.1-beta.2" />
<PackageVersion Include="eShop.ServiceDefaults.Depi" Version="1.0.1-beta.2" />
<PackageReference Include="eShop.ServiceDefaults.Depi" />
paket add eShop.ServiceDefaults.Depi --version 1.0.1-beta.2
#r "nuget: eShop.ServiceDefaults.Depi, 1.0.1-beta.2"
#:package eShop.ServiceDefaults.Depi@1.0.1-beta.2
#addin nuget:?package=eShop.ServiceDefaults.Depi&version=1.0.1-beta.2&prerelease
#tool nuget:?package=eShop.ServiceDefaults.Depi&version=1.0.1-beta.2&prerelease
eShop.ServiceDefaults
Shared defaults for ASP.NET Core microservices used in eShop-style distributed systems.
This package centralizes common service setup so each microservice can start with consistent observability, health checks, and authentication behavior.
Features
- OpenTelemetry logging, metrics, and tracing setup
- OTLP exporter support via configuration
- Default health checks (
/health,/alivein development) - Standard HTTP resilience handlers for
HttpClient - JWT bearer authentication setup from configuration
- Outgoing
HttpClientbearer token forwarding from current HTTP context - Small helpers for claim access and required configuration values
Target Framework
.NET 10(net10.0)
Install
dotnet add package eShop.ServiceDefaults
Quick Start
In your service startup (for example Program.cs):
using eShop.ServiceDefaults;
var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();
builder.AddDefaultAuthentication();
var app = builder.Build();
app.MapDefaultEndpoints();
app.Run();
Configuration
Authentication
AddDefaultAuthentication is enabled only when the Identity section exists.
{
"Identity": {
"Url": "http://identity",
"Audience": "basket"
}
}
Notes:
subclaim remapping is disabled to preserve the original subject claim.RequireHttpsMetadatais set tofalse.- Audience validation is disabled (
ValidateAudience = false).
OpenTelemetry Export
OTLP exporting is enabled when OTEL_EXPORTER_OTLP_ENDPOINT is set.
Example:
export OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317
Provided Extensions
IHostApplicationBuilder
AddServiceDefaults()- Calls
AddBasicServiceDefaults() - Configures default
HttpClientresilience handlers - Includes commented hooks for service discovery
- Calls
AddBasicServiceDefaults()- Adds default health checks
- Configures OpenTelemetry
ConfigureOpenTelemetry()- Adds OpenTelemetry logging
- Adds metrics: ASP.NET Core, HTTP client, runtime, and
Experimental.Microsoft.Extensions.AImeter - Adds tracing: ASP.NET Core, gRPC client, HTTP client, and
Experimental.Microsoft.Extensions.AIsource - Uses
AlwaysOnSamplerin development
AddDefaultHealthChecks()- Registers
selfhealth check tagged withlive
- Registers
AddDefaultAuthentication()- Adds JWT bearer authentication and authorization when
Identityconfiguration exists
- Adds JWT bearer authentication and authorization when
WebApplication
MapDefaultEndpoints()- In development only:
- Maps
/healthfor readiness - Maps
/alivefor liveness checks (livetag)
- Maps
- In development only:
IHttpClientBuilder
AddAuthToken()- Adds a delegating handler that reads
access_tokenfrom the current request context - Forwards token as
Authorization: Bearer <token>on outgoing requests
- Adds a delegating handler that reads
ClaimsPrincipal
GetUserId()→ readssubGetUserName()→ readsClaimTypes.Name
IConfiguration
GetRequiredValue(name)→ throws if value is missing
Development Notes
- Health endpoints are intentionally mapped only in development by default.
- Service discovery hooks are present in code but currently commented out.
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Asp.Versioning.Mvc.ApiExplorer (>= 8.1.1)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 10.0.5)
- Microsoft.AspNetCore.OpenApi (>= 10.0.5)
- Microsoft.Extensions.Http.Resilience (>= 8.0.0)
- Microsoft.Extensions.ServiceDiscovery (>= 8.0.0)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.8.1)
- OpenTelemetry.Extensions.Hosting (>= 1.8.1)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.8.1)
- OpenTelemetry.Instrumentation.GrpcNetClient (>= 1.9.0-beta.1)
- OpenTelemetry.Instrumentation.Http (>= 1.8.1)
- OpenTelemetry.Instrumentation.Runtime (>= 1.8.1)
- Scalar.AspNetCore (>= 2.13.22)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.1-beta.2 | 83 | 4/19/2026 |
| 1.0.0-preview1 | 73 | 4/6/2026 |
| 1.0.0-beta.2 | 142 | 4/17/2026 |
| 1.0.0-beta.1 | 105 | 4/11/2026 |