![]() |
VOOZH | about |
dotnet add package Couchbase.Aspire.Client --version 1.0.0-beta.5
NuGet\Install-Package Couchbase.Aspire.Client -Version 1.0.0-beta.5
<PackageReference Include="Couchbase.Aspire.Client" Version="1.0.0-beta.5" />
<PackageVersion Include="Couchbase.Aspire.Client" Version="1.0.0-beta.5" />Directory.Packages.props
<PackageReference Include="Couchbase.Aspire.Client" />Project file
paket add Couchbase.Aspire.Client --version 1.0.0-beta.5
#r "nuget: Couchbase.Aspire.Client, 1.0.0-beta.5"
#:package Couchbase.Aspire.Client@1.0.0-beta.5
#addin nuget:?package=Couchbase.Aspire.Client&version=1.0.0-beta.5&prereleaseInstall as a Cake Addin
#tool nuget:?package=Couchbase.Aspire.Client&version=1.0.0-beta.5&prereleaseInstall as a Cake Tool
Registers IClusterProvider and IBucketProvider in the DI container for connecting Couchbase databases.
dotnet add package Couchbase.Aspire.Client
In the AppHost.cs file of your project, call the AddCouchbaseClient extension method to register IClusterProvider and IBucketProvider for use via the dependency injection container. The method takes a connection name parameter.
builder.AddCouchbaseClient("couchbase");
You can then retrieve the IClusterProvider and IBucketProvider instances using dependency injection. For example, to retrieve a connection from a Web API controller:
private readonly IBucketProvider _bucketProvider;
public ProductsController(IBucketProvider bucketProvider)
{
_bucketProvider = bucketProvider;
}
If the connection string includes a bucket name, you can get the bucket instance via INamedBucketProvider without specifying the bucket name again:
private readonly INamedBucketProvider _bucketProvider;
public ProductsController(INamedBucketProvider bucketProvider)
{
_bucketProvider = bucketProvider;
}
The Aspire Couchbase component offers various options for configuring the database connection according to your project's requirements and conventions.
When using a connection string from the ConnectionStrings configuration section, you can provide the name of the connection string as the parameter when calling AddCouchbaseClient:
builder.AddCouchbaseClient("myConnection");
And then the connection string will be retrieved from the ConnectionStrings configuration section:
{
"ConnectionStrings": {
"myConnection": "couchbases://username:password@server1:11207,server2:11207/mybucket?option1=value1&option2=value2"
}
}
See the ConnectionString documentation for more information on how to format this connection string. Couchbase.Aspire.Client extends the standard connection string format by allowing the inclusion of the username, password, and bucket name directly in the connection string.
The Aspire Couchbase component supports Microsoft.Extensions.Configuration. It loads the CouchbaseClientSettings from configuration by using the Aspire:Couchbase:Client key. Example appsettings.json that configures some of the options:
{
"Aspire": {
"Couchbase": {
"Client": {
"ConnectionString": "couchbases://server:port",
"Username": "username",
"Password": "password",
"BucketName": "mybucket", // Optional bucket name
"DisableHealthChecks": false,
"DisableTracing": false,
"HealthChecks": {
"Type": "Active",
"MinimumHealthyNodes": {
"KeyValue": 2,
"Query": 2
},
"MaximumUnhealthyNodes": {
"KeyValue": 0,
"Query": 1
}
}
}
}
}
You can also pass the Action<CouchbaseClientSettings> delegate to set up some or all of the options inline:
builder.AddCouchbaseClient("couchbase",
settings => settings.ConnectionString = "couchbases://server:port");
Further tuning of ClusterOptions can be done by passing an additional Action<ClusterOptions> delegate:
builder.AddCouchbaseClient("couchbase",
settings => settings.ConnectionString = "couchbases://server:port",
options => options.WithSerializer(SystemTextJsonSerializer.Create());
In your AppHost project, install the Couchbase.Aspire.Hosting library with NuGet:
dotnet add package Couchbase.Aspire.Hosting
Then, in the AppHost.cs file of your project, register a Couchbase cluster and consume the connection using the following methods:
var couchbase = builder.AddCouchbase("couchbase");
var bucket = couchbase.AddBucket("mybucket");
var myService = builder.AddProject<Projects.MyService>()
.WithReference(bucket)
.WaitFor(bucket);
// Alternatively, reference the cluster rather than a specific bucket, INamedBucketProvider will not be registered in DI
var myService2 = builder.AddProject<Projects.MyService>()
.WithReference(couchbase)
.WaitFor(couchbase);
The WithReference method configures a connection to a bucket in the MyService project named mybucket. In the Program.cs file of MyService, the database connection can be consumed using:
builder.AddCouchbaseClient("mybucket");
By default, health checks are enabled with the following configuration:
These defaults can be overridden using configuration providers or inline delegates as described in the Configuration section above.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on Couchbase.Aspire.Client:
| Package | Downloads |
|---|---|
|
Couchbase.Aspire.Client.DistributedCaching
A Couchbase implementation for IDistributedCache that integrates with Aspire, including health checks, logging, and telemetry. |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-beta.5 | 184 | 4/28/2026 |
| 1.0.0-beta.4 | 321 | 4/21/2026 |
| 1.0.0-beta.3 | 178 | 4/4/2026 |
| 1.0.0-beta.2 | 1,278 | 3/6/2026 |
| 1.0.0-beta.1 | 1,838 | 2/27/2026 |
| 1.0.0-alpha.5 | 72 | 2/26/2026 |
| 1.0.0-alpha.4 | 83 | 1/25/2026 |
| 1.0.0-alpha.3 | 71 | 1/19/2026 |
| 1.0.0-alpha.2 | 79 | 1/17/2026 |
| 1.0.0-alpha.1 | 80 | 1/16/2026 |