コンテンツにスキップ
ドキュメントAspire を試す
ドキュメント試す

Set up KurrentDB in the AppHost

このコンテンツはまだ日本語訳がありません。

⭐ Community Toolkit KurrentDB logo

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.

To start building an Aspire app that uses KurrentDB, install the 📦 CommunityToolkit.Aspire.Hosting.KurrentDB NuGet package:

Terminal
aspire add CommunityToolkit.Aspire.Hosting.KurrentDB

Learn more about aspire add in the command reference.

This updates your aspire.config.json with the KurrentDB hosting integration package:

aspire.config.json
{
"packages": {
"CommunityToolkit.Aspire.Hosting.KurrentDB": "*"
}
}

Once you’ve installed the hosting integration in your AppHost project, you can add a KurrentDB resource as shown in the following example:

apphost.mts
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
();
  1. When Aspire adds a container image to the AppHost, as shown in the preceding example with the docker.kurrent.io/kurrent-latest/kurrentdb image, it creates a new KurrentDB instance on your local machine.

  2. The AppHost reference call configures a connection in the consuming project named after the referenced KurrentDB resource, such as kurrentdb in the preceding example.

Add a data volume to the KurrentDB resource as shown in the following example:

apphost.mts
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:

apphost.mts
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.

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.