# CosmosDatabaseBuilder Methods

- Package: [Aspire.Microsoft.Azure.Cosmos](/reference/api/csharp/aspire.microsoft.azure.cosmos.md)
- Type: [CosmosDatabaseBuilder](/reference/api/csharp/aspire.microsoft.azure.cosmos/cosmosdatabasebuilder.md)
- Kind: `Methods`
- Members: `1`

Represents a builder that can be used to register multiple container instances against the same Cosmos database connection.

## AddKeyedContainer(string)

- Name: `AddKeyedContainer(string)`
- Returns: [CosmosDatabaseBuilder](/reference/api/csharp/aspire.microsoft.azure.cosmos/cosmosdatabasebuilder.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Components/Aspire.Microsoft.Azure.Cosmos/CosmosDatabaseBuilder.cs#L62-L79)

Register a `Cosmos.Container` against the database managed with [CosmosDatabaseBuilder](/reference/api/csharp/aspire.microsoft.azure.cosmos/cosmosdatabasebuilder.md) as a keyed singleton.

```csharp
public sealed class CosmosDatabaseBuilder
{
    public CosmosDatabaseBuilder AddKeyedContainer(
        string name)
    {
        // ...
    }
}
```

## Parameters

- `name` (`string`)
  The name of the container to register.

## Returns

[CosmosDatabaseBuilder](/reference/api/csharp/aspire.microsoft.azure.cosmos/cosmosdatabasebuilder.md) -- A [CosmosDatabaseBuilder](/reference/api/csharp/aspire.microsoft.azure.cosmos/cosmosdatabasebuilder.md) that can be used for further chaining.
