# QdrantBuilderExtensions Methods

- Package: [Aspire.Hosting.Qdrant](/reference/api/csharp/aspire.hosting.qdrant.md)
- Type: [QdrantBuilderExtensions](/reference/api/csharp/aspire.hosting.qdrant/qdrantbuilderextensions.md)
- Kind: `Methods`
- Members: `5`

Provides extension methods for adding Qdrant resources to the application model.

## AddQdrant(IDistributedApplicationBuilder, string, IResourceBuilder<ParameterResource>, int?, int?)

- Name: `AddQdrant(IDistributedApplicationBuilder, string, IResourceBuilder<ParameterResource>, int?, int?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<QdrantServerResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs#L45-L99)

Adds a Qdrant resource to the application. A container is used for local development.

```csharp
public static class QdrantBuilderExtensions
{
    public static IResourceBuilder<QdrantServerResource> AddQdrant(
        this IDistributedApplicationBuilder builder,
        string name,
        IResourceBuilder<ParameterResource>? apiKey = null,
        int? grpcPort = null,
        int? httpPort = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The `Hosting.IDistributedApplicationBuilder`.
- `name` (`string`)
  The name of the resource. This name will be used as the connection string name when referenced in a dependency
- `apiKey` (`IResourceBuilder<ParameterResource>`) `optional`
  The parameter used to provide the API Key for the Qdrant resource. If `null` a random key will be generated as {name}-Key.
- `grpcPort` (`int?`) `optional`
  The host port of gRPC endpoint of Qdrant database.
- `httpPort` (`int?`) `optional`
  The host port of HTTP endpoint of Qdrant database.

## Returns

`IResourceBuilder<QdrantServerResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## Remarks

The .NET client library uses the gRPC port by default to communicate and this resource exposes that endpoint. This version of the package defaults to the tag of the container image.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithDataBindMount(IResourceBuilder<QdrantServerResource>, string, bool)

- Name: `WithDataBindMount(IResourceBuilder<QdrantServerResource>, string, bool)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<QdrantServerResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs#L130-L133)

Adds a bind mount for the data folder to a Qdrant container resource.

```csharp
public static class QdrantBuilderExtensions
{
    public static IResourceBuilder<QdrantServerResource> WithDataBindMount(
        this IResourceBuilder<QdrantServerResource> builder,
        string source,
        bool isReadOnly = false)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<QdrantServerResource>`)
  The resource builder.
- `source` (`string`)
  The source directory on the host to mount into the container.
- `isReadOnly` (`bool`) `optional`
  A flag that indicates if this is a read-only mount.

## Returns

`IResourceBuilder<QdrantServerResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithDataVolume(IResourceBuilder<QdrantServerResource>, string?, bool)

- Name: `WithDataVolume(IResourceBuilder<QdrantServerResource>, string?, bool)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<QdrantServerResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs#L113-L116)

Adds a named volume for the data folder to a Qdrant container resource.

```csharp
public static class QdrantBuilderExtensions
{
    public static IResourceBuilder<QdrantServerResource> WithDataVolume(
        this IResourceBuilder<QdrantServerResource> builder,
        string? name = null,
        bool isReadOnly = false)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<QdrantServerResource>`)
  The resource builder.
- `name` (`string?`) `optional`
  The name of the volume. Defaults to an auto-generated name based on the resource name.
- `isReadOnly` (`bool`) `optional`
  A flag that indicates if this is a read-only volume.

## Returns

`IResourceBuilder<QdrantServerResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithReference(IResourceBuilder<TDestination>, IResourceBuilder<QdrantServerResource>)

- Name: `WithReference(IResourceBuilder<TDestination>, IResourceBuilder<QdrantServerResource>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<TDestination>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs#L149)

Adds a reference to a Qdrant server to the resource.

```csharp
public static class QdrantBuilderExtensions
{
    public static IResourceBuilder<TDestination> WithReference<TDestination>(
        this IResourceBuilder<TDestination> builder,
        IResourceBuilder<QdrantServerResource> qdrantResource)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<TDestination>`)
  The resource builder for the destination resource.
- `qdrantResource` (`IResourceBuilder<QdrantServerResource>`)
  The Qdrant server resource.

## Returns

`IResourceBuilder<TDestination>` -- The `ApplicationModel.IResourceBuilder`1`.

## Remarks

This overload is not available in polyglot app hosts. Use the overload that accepts an explicit connection name instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithReference(IResourceBuilder<TDestination>, IResourceBuilder<QdrantServerResource>, string?)

- Name: `WithReference(IResourceBuilder<TDestination>, IResourceBuilder<QdrantServerResource>, string?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<TDestination>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs#L163-L190)

Adds a reference to a Qdrant server to the resource.

```csharp
public static class QdrantBuilderExtensions
{
    public static IResourceBuilder<TDestination> WithReference<TDestination>(
        this IResourceBuilder<TDestination> builder,
        IResourceBuilder<QdrantServerResource> qdrantResource,
        string? connectionName = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<TDestination>`)
  The resource builder for the destination resource.
- `qdrantResource` (`IResourceBuilder<QdrantServerResource>`)
  The Qdrant server resource.
- `connectionName` (`string?`) `optional`
  An override of the source resource's name for the connection string. The resulting connection string will be "ConnectionStrings__connectionName" if this is not null.

## Returns

`IResourceBuilder<TDestination>` -- The `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.
