Set up KurrentDB in the AppHost
This article is the reference for the Aspire KurrentDB Hosting integration. It enumerates the AppHost APIs that you use to model a KurrentDB resource in your AppHost project.
If you’re new to the KurrentDB integration, start with the Get started with KurrentDB integrations guide. For how consuming apps read the connection information this page exposes, see Connect to KurrentDB.
Installation
Section titled “Installation”To start building an Aspire app that uses KurrentDB, install the 📦 CommunityToolkit.Aspire.Hosting.KurrentDB NuGet package:
aspire add communitytoolkit-kurrentdbThe Aspire CLI is interactive, be sure to select the appropriate search result when prompted:
Select an integration to add:
> communitytoolkit-kurrentdb (CommunityToolkit.Aspire.Hosting.KurrentDB)> Other results listed as selectable options...#:package CommunityToolkit.Aspire.Hosting.KurrentDB@*<PackageReference Include="CommunityToolkit.Aspire.Hosting.KurrentDB" Version="*" />Or, choose a manual installation approach:
#:package CommunityToolkit.Aspire.Hosting.KurrentDB@*<PackageReference Include="CommunityToolkit.Aspire.Hosting.KurrentDB" Version="*" />aspire add CommunityToolkit.Aspire.Hosting.KurrentDBLearn more about aspire add in the command reference.
This updates your aspire.config.json with the KurrentDB hosting integration package:
{ "packages": { "CommunityToolkit.Aspire.Hosting.KurrentDB": "*" }}Add KurrentDB resource
Section titled “Add KurrentDB resource”Once you’ve installed the hosting integration in your AppHost project, you can add a KurrentDB resource as shown in the following example:
var builder = DistributedApplication.CreateBuilder(args);
var kurrentdb = builder.AddKurrentDB("kurrentdb");
var exampleProject = builder.AddProject<Projects.ExampleProject>("apiservice") .WithReference(kurrentdb);
builder.Build().Run();import { function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder } from './.aspire/modules/aspire.mjs';
const const builder: IDistributedApplicationBuilder
builder = await function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder();
const const kurrentdb: KurrentDBResource
kurrentdb = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addKurrentDB(name: string, options?: { port?: number;}): KurrentDBResource (+1 overload)
Adds a KurrentDB resource to the application model. A container is used for local development. The default image is and the tag is .
addKurrentDB("kurrentdb");
const const exampleProject: ProjectResource
exampleProject = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addProject(name: string, projectPath: string, options?: { launchProfileOrOptions?: ProjectResourceOptions;}): ProjectResource (+1 overload)
Adds a .NET project resource
addProject("apiservice", "../ExampleProject/ExampleProject.csproj");await const exampleProject: ProjectResource
exampleProject.ProjectResource.withReference(source: EndpointReference | string | uri, options?: { connectionName?: string; optional?: boolean; name?: string;} | undefined): ProjectResource (+1 overload)
Adds a reference to another resource
withReference(const kurrentdb: KurrentDBResource
kurrentdb);
await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.build(): DistributedApplication
Builds the distributed application
build().DistributedApplication.run(cancellationToken?: cancellationToken): void
Runs the distributed application
run();-
When Aspire adds a container image to the AppHost, as shown in the preceding example with the
docker.kurrent.io/kurrent-latest/kurrentdbimage, it creates a new KurrentDB instance on your local machine. -
The AppHost reference call configures a connection in the consuming project named after the referenced KurrentDB resource, such as
kurrentdbin the preceding example.
Add KurrentDB resource with data volume
Section titled “Add KurrentDB resource with data volume”Add a data volume to the KurrentDB resource as shown in the following example:
var builder = DistributedApplication.CreateBuilder(args);
var kurrentdb = builder.AddKurrentDB("kurrentdb") .WithDataVolume();
var exampleProject = builder.AddProject<Projects.ExampleProject>("apiservice") .WithReference(kurrentdb);
builder.Build().Run();import { function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder } from './.aspire/modules/aspire.mjs';
const const builder: IDistributedApplicationBuilder
builder = await function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder();
const const kurrentdb: KurrentDBResource
kurrentdb = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addKurrentDB(name: string, options?: { port?: number;}): KurrentDBResource (+1 overload)
Adds a KurrentDB resource to the application model. A container is used for local development. The default image is and the tag is .
addKurrentDB("kurrentdb");await const kurrentdb: KurrentDBResource
kurrentdb.KurrentDBResource.withDataVolume(options?: { name?: string;}): KurrentDBResource (+1 overload)
Adds a named volume for the data folder to a KurrentDB container resource.
withDataVolume();
const const exampleProject: ProjectResource
exampleProject = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addProject(name: string, projectPath: string, options?: { launchProfileOrOptions?: ProjectResourceOptions;}): ProjectResource (+1 overload)
Adds a .NET project resource
addProject("apiservice", "../ExampleProject/ExampleProject.csproj");await const exampleProject: ProjectResource
exampleProject.ProjectResource.withReference(source: EndpointReference | string | uri, options?: { connectionName?: string; optional?: boolean; name?: string;} | undefined): ProjectResource (+1 overload)
Adds a reference to another resource
withReference(const kurrentdb: KurrentDBResource
kurrentdb);
await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.build(): DistributedApplication
Builds the distributed application
build().DistributedApplication.run(cancellationToken?: cancellationToken): void
Runs the distributed application
run();The data volume is used to persist KurrentDB data outside the lifecycle of its container. The data volume is mounted at the /var/lib/kurrentdb path in the KurrentDB container, and when a name parameter isn’t provided, the name is generated at random. For more information on data volumes and details on why they’re preferred over bind mounts, see Docker docs: Volumes.
Add KurrentDB resource with data bind mount
Section titled “Add KurrentDB resource with data bind mount”Add a data bind mount to the KurrentDB resource as shown in the following example:
var builder = DistributedApplication.CreateBuilder(args);
var kurrentdb = builder.AddKurrentDB("kurrentdb") .WithDataBindMount(source: @"C:\KurrentDB\Data");
var exampleProject = builder.AddProject<Projects.ExampleProject>("apiservice") .WithReference(kurrentdb);
builder.Build().Run();import { function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder } from './.aspire/modules/aspire.mjs';
const const builder: IDistributedApplicationBuilder
builder = await function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder();
const const kurrentdb: KurrentDBResource
kurrentdb = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addKurrentDB(name: string, options?: { port?: number;}): KurrentDBResource (+1 overload)
Adds a KurrentDB resource to the application model. A container is used for local development. The default image is and the tag is .
addKurrentDB("kurrentdb");await const kurrentdb: KurrentDBResource
kurrentdb.KurrentDBResource.withDataBindMount(source: string): KurrentDBResource
Adds a bind mount for the data folder to a KurrentDB container resource.
withDataBindMount("C:\\KurrentDB\\Data");
const const exampleProject: ProjectResource
exampleProject = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addProject(name: string, projectPath: string, options?: { launchProfileOrOptions?: ProjectResourceOptions;}): ProjectResource (+1 overload)
Adds a .NET project resource
addProject("apiservice", "../ExampleProject/ExampleProject.csproj");await const exampleProject: ProjectResource
exampleProject.ProjectResource.withReference(source: EndpointReference | string | uri, options?: { connectionName?: string; optional?: boolean; name?: string;} | undefined): ProjectResource (+1 overload)
Adds a reference to another resource
withReference(const kurrentdb: KurrentDBResource
kurrentdb);
await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.build(): DistributedApplication
Builds the distributed application
build().DistributedApplication.run(cancellationToken?: cancellationToken): void
Runs the distributed application
run();Data bind mounts rely on the host machine’s filesystem to persist KurrentDB data across container restarts. The data bind mount is mounted at the C:\KurrentDB\Data on Windows (or /KurrentDB/Data on Unix) path on the host machine in the KurrentDB container. For more information on data bind mounts, see Docker docs: Bind mounts.
Hosting integration health checks
Section titled “Hosting integration health checks”The KurrentDB hosting integration automatically adds a health check for the KurrentDB resource. The health check verifies that the KurrentDB instance is running and that a connection can be established to it. The health check is wired into the /health HTTP endpoint, where all registered health checks must pass before the app is considered ready to accept traffic.