KurrentDB Client integration reference
To get started with the Aspire KurrentDB integrations, follow the Get started with KurrentDB integrations guide.
This article includes full details about the Aspire KurrentDB Client integration.
Installation
Section titled “Installation”To install the 📦 CommunityToolkit.Aspire.KurrentDB NuGet package in the client-consuming project:
dotnet add package CommunityToolkit.Aspire.KurrentDB#:package CommunityToolkit.Aspire.KurrentDB@*<PackageReference Include="CommunityToolkit.Aspire.KurrentDB" Version="*" />Add KurrentDB client
Section titled “Add KurrentDB client”In the Program.cs file of your client-consuming project, call the AddKurrentDBClient extension to register a KurrentDBClient for use via the dependency injection container.
builder.AddKurrentDBClient(connectionName: "kurrentdb");You can then retrieve the KurrentDBClient instance using dependency injection. For example, to retrieve the client from a service:
public class ExampleService(KurrentDBClient client){ // Use client...}Add keyed KurrentDB client
Section titled “Add keyed KurrentDB client”There might be situations where you want to register multiple KurrentDBClient instances with different connection names. To register keyed KurrentDB clients, call the AddKeyedKurrentDBClient method:
builder.AddKeyedKurrentDBClient(name: "events");builder.AddKeyedKurrentDBClient(name: "audit");Then retrieve the instances using dependency injection:
public class ExampleService( [FromKeyedServices("events")] KurrentDBClient eventsClient, [FromKeyedServices("audit")] KurrentDBClient auditClient){ // Use clients...}For more information on keyed services, see .NET dependency injection: Keyed services.
Configuration
Section titled “Configuration”The KurrentDB client integration provides multiple configuration approaches and options to meet the requirements and conventions of your project.
Use a connection string
Section titled “Use a connection string”When using a connection string from the ConnectionStrings configuration section, you can provide the name of the connection string when calling AddKurrentDBClient:
builder.AddKurrentDBClient("kurrentdb");Then the connection string will be retrieved from the ConnectionStrings configuration section:
{ "ConnectionStrings": { "kurrentdb": "kurrentdb://localhost:22113?tls=false" }}Use configuration providers
Section titled “Use configuration providers”The KurrentDB client integration supports Microsoft.Extensions.Configuration. It loads the KurrentDBSettings from configuration using the Aspire:KurrentDB:Client key. Example appsettings.json:
{ "Aspire": { "KurrentDB": { "Client": { "ConnectionString": "kurrentdb://localhost:22113?tls=false", "DisableHealthChecks": false, "DisableTracing": false } } }}Use inline delegates
Section titled “Use inline delegates”You can pass the delegate to set up options inline:
builder.AddKurrentDBClient( "kurrentdb", static settings => settings.DisableHealthChecks = true);Client integration health checks
Section titled “Client integration health checks”By default, Aspire integrations enable health checks for all services. The KurrentDB integration adds a health check that verifies the KurrentDB instance is reachable and can execute commands.
Observability and telemetry
Section titled “Observability and telemetry”Logging
Section titled “Logging”The KurrentDB integration uses the following log categories:
Aspire.KurrentDB
Tracing
Section titled “Tracing”The KurrentDB integration emits tracing activities using OpenTelemetry when tracing is not disabled.