eShop.ServiceDefaults.Depi 1.0.1-beta.2

This is a prerelease version of eShop.ServiceDefaults.Depi.
dotnet add package eShop.ServiceDefaults.Depi --version 1.0.1-beta.2
                    
NuGet\Install-Package eShop.ServiceDefaults.Depi -Version 1.0.1-beta.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="eShop.ServiceDefaults.Depi" Version="1.0.1-beta.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="eShop.ServiceDefaults.Depi" Version="1.0.1-beta.2" />
                    
Directory.Packages.props
<PackageReference Include="eShop.ServiceDefaults.Depi" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add eShop.ServiceDefaults.Depi --version 1.0.1-beta.2
                    
#r "nuget: eShop.ServiceDefaults.Depi, 1.0.1-beta.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package eShop.ServiceDefaults.Depi@1.0.1-beta.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=eShop.ServiceDefaults.Depi&version=1.0.1-beta.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=eShop.ServiceDefaults.Depi&version=1.0.1-beta.2&prerelease
                    
Install as a Cake Tool

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, /alive in development)
  • Standard HTTP resilience handlers for HttpClient
  • JWT bearer authentication setup from configuration
  • Outgoing HttpClient bearer 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:

  • sub claim remapping is disabled to preserve the original subject claim.
  • RequireHttpsMetadata is set to false.
  • 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 HttpClient resilience handlers
    • Includes commented hooks for service discovery
  • AddBasicServiceDefaults()

    • Adds default health checks
    • Configures OpenTelemetry
  • ConfigureOpenTelemetry()

    • Adds OpenTelemetry logging
    • Adds metrics: ASP.NET Core, HTTP client, runtime, and Experimental.Microsoft.Extensions.AI meter
    • Adds tracing: ASP.NET Core, gRPC client, HTTP client, and Experimental.Microsoft.Extensions.AI source
    • Uses AlwaysOnSampler in development
  • AddDefaultHealthChecks()

    • Registers self health check tagged with live
  • AddDefaultAuthentication()

    • Adds JWT bearer authentication and authorization when Identity configuration exists

WebApplication

  • MapDefaultEndpoints()
    • In development only:
      • Maps /health for readiness
      • Maps /alive for liveness checks (live tag)

IHttpClientBuilder

  • AddAuthToken()
    • Adds a delegating handler that reads access_token from the current request context
    • Forwards token as Authorization: Bearer <token> on outgoing requests

ClaimsPrincipal

  • GetUserId() → reads sub
  • GetUserName() → reads ClaimTypes.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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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