Qdrant integration
Qdrant is an open-source vector similarity search engine that efficiently stores, indexes, and searches large-scale vector data. It’s commonly used in machine learning, artificial intelligence, and data science applications.
Vector data encodes information as mathematical vectors, which are arrays of numbers or coordinates. Machine learning and AI systems often use vectors to represent unstructured objects like images, text, audio, or video.
Hosting integration
Section titled “Hosting integration”The Qdrant hosting integration models the server as the QdrantServerResource type. To access this type and APIs, add the 📦 Aspire.Hosting.Qdrant NuGet package in your AppHost project:
aspire add qdrantThe Aspire CLI is interactive, be sure to select the appropriate search result when prompted:
Select an integration to add:
> qdrant (Aspire.Hosting.Qdrant)> Other results listed as selectable options...#:package Aspire.Hosting.Qdrant@*<PackageReference Include="Aspire.Hosting.Qdrant" Version="*" />Add Qdrant resource
Section titled “Add Qdrant resource”In your AppHost project, call AddQdrant to add and return a Qdrant resource builder:
var builder = DistributedApplication.CreateBuilder(args);
var qdrant = builder.AddQdrant("qdrant") .WithLifetime(ContainerLifetime.Persistent);
var myService = builder.AddProject<Projects.ExampleProject>() .WithReference(qdrant) .WaitFor(qdrant);The WithReference method configures a connection in the ExampleProject named qdrant.
Handling API keys and parameters
Section titled “Handling API keys and parameters”To connect to Qdrant a client must pass the right API key. When Aspire adds a Qdrant resource, it sets the API key to a random string. To use a specific API key, pass it as an apiKey parameter:
var apiKey = builder.AddParameter("apiKey", secret: true);
var qdrant = builder.AddQdrant("qdrant", apiKey);
var myService = builder.AddProject<Projects.ExampleProject>() .WithReference(qdrant);For more information, see External parameters.
Add Qdrant resource with data volume
Section titled “Add Qdrant resource with data volume”To add a data volume to the Qdrant resource, call the WithDataVolume extension method:
var builder = DistributedApplication.CreateBuilder(args);
var qdrant = builder.AddQdrant("qdrant") .WithLifetime(ContainerLifetime.Persistent) .WithDataVolume();
var myService = builder.AddProject<Projects.ExampleProject>() .WithReference(qdrant) .WaitFor(qdrant);The data volume is used to persist the Qdrant data outside the lifecycle of its container. The data volume is mounted at the /qdrant/storage path.
Add Qdrant resource with data bind mount
Section titled “Add Qdrant resource with data bind mount”To add a data bind mount to the Qdrant resource, call the WithDataBindMount method:
var builder = DistributedApplication.CreateBuilder(args);
var qdrant = builder.AddQdrant("qdrant") .WithLifetime(ContainerLifetime.Persistent) .WithDataBindMount(source: @"C:\Qdrant\Data");
var myService = builder.AddProject<Projects.ExampleProject>() .WithReference(qdrant) .WaitFor(qdrant);Hosting integration health checks
Section titled “Hosting integration health checks”The Qdrant hosting integration automatically adds a health check for the Qdrant resource. The health check verifies that Qdrant is running and that a connection can be established to it.
Client integration
Section titled “Client integration”To get started with the Aspire Qdrant client integration, install the 📦 Aspire.Qdrant.Client NuGet package:
dotnet add package Aspire.Qdrant.Client#:package Aspire.Qdrant.Client@*<PackageReference Include="Aspire.Qdrant.Client" Version="*" />The Qdrant client integration registers a QdrantClient instance that you can use to interact with Qdrant vector data.
Add a Qdrant client
Section titled “Add a Qdrant client”In the Program.cs file, call the AddQdrantClient extension method to register a QdrantClient:
builder.AddQdrantClient("qdrant");You can then retrieve the QdrantClient instance using dependency injection:
public class ExampleService(QdrantClient client){ // Use client...}Add keyed Qdrant client
Section titled “Add keyed Qdrant client”There might be situations where you want to register multiple QdrantClient instances. To register keyed Qdrant clients, call the AddKeyedQdrantClient method:
builder.AddKeyedQdrantClient(name: "mainQdrant");builder.AddKeyedQdrantClient(name: "loggingQdrant");Then retrieve the instances:
public class ExampleService( [FromKeyedServices("mainQdrant")] QdrantClient mainQdrantClient, [FromKeyedServices("loggingQdrant")] QdrantClient loggingQdrantClient){ // Use clients...}Configuration
Section titled “Configuration”Use a connection string
Section titled “Use a connection string”When using a connection string from the ConnectionStrings configuration section:
builder.AddQdrantClient("qdrant");Then Aspire retrieves the connection string:
{ "ConnectionStrings": { "qdrant": "Endpoint=http://localhost:6334;Key=123456!@#$%" }}By default the QdrantClient uses the gRPC API endpoint.
Use configuration providers
Section titled “Use configuration providers”The Qdrant client integration supports Microsoft.Extensions.Configuration. Example appsettings.json:
{ "Aspire": { "Qdrant": { "Client": { "Endpoint": "http://localhost:6334/", "Key": "123456!@#$%" } } }}Use inline delegates
Section titled “Use inline delegates”You can pass the delegate to set up options inline:
builder.AddQdrantClient( "qdrant", settings => settings.Key = "12345!@#$%");Client integration health checks
Section titled “Client integration health checks”By default, Aspire integrations enable health checks for all services.
Observability and telemetry
Section titled “Observability and telemetry”Logging
Section titled “Logging”The Qdrant integration uses the Qdrant.Client log category.
Tracing and Metrics
Section titled “Tracing and Metrics”The Qdrant integration doesn’t currently emit tracing activities or metrics because they are not supported by the Qdrant.Client library.