# MilvusBuilderExtensions Methods

- Package: [Aspire.Hosting.Milvus](/reference/api/csharp/aspire.hosting.milvus.md)
- Type: [MilvusBuilderExtensions](/reference/api/csharp/aspire.hosting.milvus/milvusbuilderextensions.md)
- Kind: `Methods`
- Members: `7`

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

## AddDatabase(IResourceBuilder<MilvusServerResource>, string, string?)

- Name: `AddDatabase(IResourceBuilder<MilvusServerResource>, string, string?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<MilvusDatabaseResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Milvus/MilvusBuilderExtensions.cs#L103-L111)

Adds a Milvus database to the application model.

```csharp
public static class MilvusBuilderExtensions
{
    public static IResourceBuilder<MilvusDatabaseResource> AddDatabase(
        this IResourceBuilder<MilvusServerResource> builder,
        string name,
        string? databaseName = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<MilvusServerResource>`)
  The Milvus server resource builder.
- `name` (`string`)
  The name of the resource. This name will be used as the connection string name when referenced in a dependency.
- `databaseName` (`string?`) `optional`
  The name of the database. If not provided, this defaults to the same value as `name`.

## Returns

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

## Remarks

This method does not actually create the database in Milvus, rather helps complete a connection string that is used by the client component. Use in application host

```csharp
var builder = DistributedApplication.CreateBuilder(args);

var booksdb = builder.AddMilvus("milvus");
  .AddDatabase("booksdb");

var api = builder.AddProject<Projects.Api>("api")
  .WithReference(booksdb);

builder.Build().Run();
```

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

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

- Name: `AddMilvus(IDistributedApplicationBuilder, string, IResourceBuilder<ParameterResource>, int?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<MilvusServerResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Milvus/MilvusBuilderExtensions.cs#L49-L72)

Adds a Milvus container resource to the application model.

```csharp
public static class MilvusBuilderExtensions
{
    public static IResourceBuilder<MilvusServerResource> AddMilvus(
        this IDistributedApplicationBuilder builder,
        string name,
        IResourceBuilder<ParameterResource>? apiKey = null,
        int? grpcPort = 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 auth key/token user for the Milvus resource.
- `grpcPort` (`int?`) `optional`
  The host port of gRPC endpoint of Milvus database.

## Returns

`IResourceBuilder<MilvusServerResource>` -- 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. A web-based administration tool for Milvus can also be added using [MilvusBuilderExtensions.WithAttu(IResourceBuilder<T>, Action<IResourceBuilder<AttuResource>>, string?)](/reference/api/csharp/aspire.hosting.milvus/milvusbuilderextensions/methods.md#withattu-iresourcebuilder-t-action-iresourcebuilder-atturesource-string). This version of the package defaults to the tag of the container image. Use in application host

```csharp
var builder = DistributedApplication.CreateBuilder(args);

var milvus = builder.AddMilvus("milvus");
var api = builder.AddProject<Projects.Api>("api")
  .WithReference(milvus);

builder.Build().Run();
```

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithAttu(IResourceBuilder<T>, Action<IResourceBuilder<AttuResource>>, string?)

- Name: `WithAttu(IResourceBuilder<T>, Action<IResourceBuilder<AttuResource>>, string?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Milvus/MilvusBuilderExtensions.cs#L142-L156)

Adds an administration and development platform for Milvus to the application model using Attu.

```csharp
public static class MilvusBuilderExtensions
{
    public static IResourceBuilder<T> WithAttu<T>(
        this IResourceBuilder<T> builder,
        Action<IResourceBuilder<AttuResource>>? configureContainer = null,
        string? containerName = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The Milvus server resource builder.
- `configureContainer` (`Action<IResourceBuilder<AttuResource>>`) `optional`
  Configuration callback for Attu container resource.
- `containerName` (`string?`) `optional`
  The name of the container (Optional).

## Returns

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

## Remarks

This version of the package defaults to the tag of the container image. Use in application host with a Milvus resource

```csharp
var builder = DistributedApplication.CreateBuilder(args);

var milvus = builder.AddMilvus("milvus")
  .WithAttu();
var api = builder.AddProject<Projects.Api>("api")
  .WithReference(milvus);

builder.Build().Run();
```

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithConfigurationBindMount(IResourceBuilder<MilvusServerResource>, string)

> **Obsolete:** Use WithConfigurationFile instead.

- Name: `WithConfigurationBindMount(IResourceBuilder<MilvusServerResource>, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<MilvusServerResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Milvus/MilvusBuilderExtensions.cs#L201-L204)

Adds a bind mount for the configuration of a Milvus container resource.

```csharp
public static class MilvusBuilderExtensions
{
    public static IResourceBuilder<MilvusServerResource> WithConfigurationBindMount(
        this IResourceBuilder<MilvusServerResource> builder,
        string configurationFilePath)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<MilvusServerResource>`)
  The resource builder.
- `configurationFilePath` (`string`)
  The configuration file on the host to mount into the container.

## Returns

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

## WithConfigurationFile(IResourceBuilder<MilvusServerResource>, string)

- Name: `WithConfigurationFile(IResourceBuilder<MilvusServerResource>, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<MilvusServerResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Milvus/MilvusBuilderExtensions.cs#L217-L226)

Copies a configuration file into a Milvus container resource.

```csharp
public static class MilvusBuilderExtensions
{
    public static IResourceBuilder<MilvusServerResource> WithConfigurationFile(
        this IResourceBuilder<MilvusServerResource> builder,
        string configurationFilePath)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<MilvusServerResource>`)
  The resource builder.
- `configurationFilePath` (`string`)
  The configuration file on the host to copy into the container.

## Returns

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

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

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

- Name: `WithDataBindMount(IResourceBuilder<MilvusServerResource>, string, bool)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<MilvusServerResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Milvus/MilvusBuilderExtensions.cs#L186-L189)

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

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

## Parameters

- `builder` (`IResourceBuilder<MilvusServerResource>`)
  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<MilvusServerResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

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

- Name: `WithDataVolume(IResourceBuilder<MilvusServerResource>, string?, bool)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<MilvusServerResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Milvus/MilvusBuilderExtensions.cs#L170-L172)

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

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

## Parameters

- `builder` (`IResourceBuilder<MilvusServerResource>`)
  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<MilvusServerResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
