From 52576586b608c2643c5e9c8b9de25a2bc15040ec Mon Sep 17 00:00:00 2001 From: David Pine Date: Wed, 22 May 2024 14:12:12 -0500 Subject: [PATCH 1/3] Add Qdrant component --- docs/database/qdrant-component.md | 137 +++++++++++++++++++++++ docs/fundamentals/components-overview.md | 2 +- docs/toc.yml | 2 + 3 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 docs/database/qdrant-component.md diff --git a/docs/database/qdrant-component.md b/docs/database/qdrant-component.md new file mode 100644 index 0000000000..bb1b56d5a2 --- /dev/null +++ b/docs/database/qdrant-component.md @@ -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.Microsoft.Data.SqlClient](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 + +``` + +--- + +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 + +``` + +--- + +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() + .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](https://learn.microsoft.com/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 + +Also you can pass the `Action 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) diff --git a/docs/fundamentals/components-overview.md b/docs/fundamentals/components-overview.md index 0064e5dc16..114fcd9358 100644 --- a/docs/fundamentals/components-overview.md +++ b/docs/fundamentals/components-overview.md @@ -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)
.NET Aspire logo. | [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)
PostgreSQL logo. | [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)
PostgreSQL logo. | [Aspire.Npgsql](https://www.nuget.org/packages/Aspire.Npgsql) | A library for accessing [PostgreSQL](https://www.npgsql.org/doc/index.html) databases. | -| Qdrant
Qdrant logo. | [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)
Qdrant logo. | [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)
.NET Aspire logo. | [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)
Redis logo. | [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)
Redis logo. | [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). | diff --git a/docs/toc.yml b/docs/toc.yml index 6bdb285732..e9669d81a2 100644 --- a/docs/toc.yml +++ b/docs/toc.yml @@ -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 From f672a4abbea0305b74ccc9b8e87d752dd5c5517e Mon Sep 17 00:00:00 2001 From: David Pine Date: Wed, 22 May 2024 14:16:54 -0500 Subject: [PATCH 2/3] Remove SQL --- docs/database/qdrant-component.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/database/qdrant-component.md b/docs/database/qdrant-component.md index bb1b56d5a2..1055dd7a1b 100644 --- a/docs/database/qdrant-component.md +++ b/docs/database/qdrant-component.md @@ -11,7 +11,7 @@ In this article, you learn how to use the .NET Aspire Qdrant component. Use this ## Get started -To get started with the .NET Aspire Qdrant component, install the [Aspire.Microsoft.Data.SqlClient](https://www.nuget.org/packages/Aspire.Qdrant.Client) NuGet package. +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) @@ -22,7 +22,7 @@ dotnet add package Qdrant.Client ### [PackageReference](#tab/package-reference) ```xml - ``` From 69fab0221415910a8bf691e4426230456e942a84 Mon Sep 17 00:00:00 2001 From: David Pine Date: Wed, 22 May 2024 14:20:37 -0500 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Cam Soper --- docs/database/qdrant-component.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/database/qdrant-component.md b/docs/database/qdrant-component.md index 1055dd7a1b..906c6bcbdd 100644 --- a/docs/database/qdrant-component.md +++ b/docs/database/qdrant-component.md @@ -101,7 +101,7 @@ By default the `QdrantClient` uses the gRPC API endpoint. ### Use configuration providers -The .NET Aspire Qdrant Client component supports [Microsoft.Extensions.Configuration](https://learn.microsoft.com/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: +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 { @@ -117,7 +117,7 @@ The .NET Aspire Qdrant Client component supports [Microsoft.Extensions.Configura ### Use inline delegates -Also you can pass the `Action configureSettings` delegate to set up some or all the options inline, for example to set the API key from code: +You can also pass the `Action 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!@#$%");