Skip to content

Add Qdrant component #965

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 137 additions & 0 deletions docs/database/qdrant-component.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
---
title: .NET Aspire Qdrant component
description: This article describes the .NET Aspire Qdrant component.
ms.topic: how-to
ms.date: 05/22/2024
---

# .NET Aspire Qdrant component

In this article, you learn how to use the .NET Aspire Qdrant component. Use this component to register a [QdrantClient](https://github.com/qdrant/qdrant-dotnet) in the DI container for connecting to a Qdrant server.

## Get started

To get started with the .NET Aspire Qdrant component, install the [Aspire.Qdrant.Client](https://www.nuget.org/packages/Aspire.Qdrant.Client) NuGet package.

### [.NET CLI](#tab/dotnet-cli)

```dotnetcli
dotnet add package Qdrant.Client
```

### [PackageReference](#tab/package-reference)

```xml
<PackageReference Include="Aspire.Qdrant.Client"
Version="[SelectVersion]" />
```

---

For more information, see [dotnet add package](/dotnet/core/tools/dotnet-add-package) or [Manage package dependencies in .NET applications](/dotnet/core/tools/dependencies).

## Example usage

In the _:::no-loc text="Program.cs":::_ file of your component-consuming project, call the `AddQdrantClient` extension method to register a `QdrantClient` for use via the dependency injection container. The method takes a connection name parameter.

```csharp
builder.AddQdrantClient("qdrant");
```

To retrieve your `QdrantClient` object consider the following example service:

```csharp
public class ExampleService(QdrantClient client)
{
// Use client...
}
```

## App host usage

To model the Qdrant server resource in the app host, install the [Aspire.Hosting.Qdrant](https://www.nuget.org/packages/Aspire.Hosting.Qdrant) NuGet package.

### [.NET CLI](#tab/dotnet-cli)

```dotnetcli
dotnet add package Aspire.Hosting.Qdrant
```

### [PackageReference](#tab/package-reference)

```xml
<PackageReference Include="Aspire.Hosting.Qdrant"
Version="[SelectVersion]" />
```

---

In your app host project, register a Qdrant server and consume the connection using the following methods:

```csharp
var qdrant = builder.AddQdrant("qdrant");

var myService = builder.AddProject<Projects.MyService>()
.WithReference(qdrant);
```

## Configuration

The .NET Aspire Qdrant Client component provides multiple options to configure the server connection based on the requirements and conventions of your project.

### 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 `builder.AddQdrantClient()`:

```csharp
builder.AddQdrantClient("qdrant");
```

And then the connection string will be retrieved from the `ConnectionStrings` configuration section:

```json
{
"ConnectionStrings": {
"qdrant": "Endpoint=http://localhost:6334;Key=123456!@#$%"
}
}
```

By default the `QdrantClient` uses the gRPC API endpoint.

### Use configuration providers

The .NET Aspire Qdrant Client component supports [Microsoft.Extensions.Configuration](/dotnet/api/microsoft.extensions.configuration). It loads the `QdrantClientSettings` from configuration by using the `Aspire:Qdrant:Client` key. Example `appsettings.json` that configures some of the options:

```json
{
"Aspire": {
"Qdrant": {
"Client": {
"Key": "123456!@#$%"
}
}
}
}
```

### Use inline delegates

You can also pass the `Action<QdrantClientSettings> configureSettings` delegate to set up some or all the options inline, for example to set the API key from code:

```csharp
builder.AddQdrantClient("qdrant", settings => settings.ApiKey = "12345!@#$%");
```

[!INCLUDE [component-observability-and-telemetry](../includes/component-observability-and-telemetry.md)]

### Logging

The .NET Aspire Qdrant component uses the following logging categories:

- "Qdrant.Client"

## See also

- [.NET Aspire components](../fundamentals/components-overview.md)
- [.NET Aspire GitHub repo](https://github.com/dotnet/aspire)
2 changes: 1 addition & 1 deletion docs/fundamentals/components-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The following table lists the .NET Aspire components currently available for use
| [Oracle Entity Framework Core](../database/oracle-entity-framework-component.md) <br/> <img src="media/icons/Aspire-logo-256.png" alt=".NET Aspire logo." role="presentation" width="64" data-linktype="relative-path"> | [Aspire.Oracle.EntityFrameworkCore](https://www.nuget.org/packages/Aspire.Oracle.EntityFrameworkCore) | A library for accessing Oracle databases with [Entity Framework Core](/ef/core). |
| [PostgreSQL Entity Framework Core](../database/postgresql-entity-framework-component.md) <br/> <img src="media/icons/PostgreSQL_logo.3colors.256x.png" alt="PostgreSQL logo." role="presentation" width="64" data-linktype="relative-path"> | [Aspire.Npgsql.EntityFrameworkCore.PostgreSQL](https://www.nuget.org/packages/Aspire.Npgsql.EntityFrameworkCore.PostgreSQL) | A library for accessing PostgreSQL databases using [Entity Framework Core](https://www.npgsql.org/efcore/index.html). |
| [PostgreSQL](../database/postgresql-component.md) <br/> <img src="media/icons/PostgreSQL_logo.3colors.256x.png" alt="PostgreSQL logo." role="presentation" width="64" data-linktype="relative-path"> | [Aspire.Npgsql](https://www.nuget.org/packages/Aspire.Npgsql) | A library for accessing [PostgreSQL](https://www.npgsql.org/doc/index.html) databases. |
| Qdrant <br/> <img src="media/icons/QdrantLogo_256x.png" alt="Qdrant logo." role="presentation" width="64" data-linktype="relative-path"> | [Aspire.Qdrant.Client](https://www.nuget.org/packages/Aspire.Qdrant.Client) | A library for accessing [Qdrant](https://qdrant.tech/) databases. |
| [Qdrant](../database/qdrant-component.md) <br/> <img src="media/icons/QdrantLogo_256x.png" alt="Qdrant logo." role="presentation" width="64" data-linktype="relative-path"> | [Aspire.Qdrant.Client](https://www.nuget.org/packages/Aspire.Qdrant.Client) | A library for accessing [Qdrant](https://qdrant.tech/) databases. |
| [RabbitMQ](../messaging/rabbitmq-client-component.md) <br/> <img src="media/icons/Aspire-logo-256.png" alt=".NET Aspire logo." role="presentation" width="64" data-linktype="relative-path"> | [Aspire.RabbitMQ.Client](https://www.nuget.org/packages/Aspire.RabbitMQ.Client) | A library for accessing [RabbitMQ](https://www.rabbitmq.com/dotnet.html). |
| [Redis Distributed Caching](../caching/stackexchange-redis-distributed-caching-component.md) <br/> <img src="media/icons/redis-cube-red_white-rgb.png" alt="Redis logo." role="presentation" width="64" data-linktype="relative-path"> | [Aspire.StackExchange.Redis.DistributedCaching](https://www.nuget.org/packages/Aspire.StackExchange.Redis.DistributedCaching) | A library for accessing [Redis](https://stackexchange.github.io/StackExchange.Redis/) caches for [distributed caching](/aspnet/core/performance/caching/distributed). |
| [Redis Output Caching](../caching/stackexchange-redis-output-caching-component.md) <br/> <img src="media/icons/redis-cube-red_white-rgb.png" alt="Redis logo." role="presentation" width="64" data-linktype="relative-path"> | [Aspire.StackExchange.Redis.OutputCaching](https://www.nuget.org/packages/Aspire.StackExchange.Redis.OutputCaching) | A library for accessing [Redis](https://stackexchange.github.io/StackExchange.Redis/) caches for [output caching](/aspnet/core/performance/caching/output). |
Expand Down
2 changes: 2 additions & 0 deletions docs/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ items:
- name: PostgreSQL
displayName: postgresql,database
href: database/postgresql-component.md
- name: Qdrant
href: database/qdrant-component.md
- name: RabbitMQ service broker
displayName: rabbitmq,messaging,service broker
href: messaging/rabbitmq-client-component.md
Expand Down
Loading