# AspireMicrosoftAzureCosmosExtensions

- Kind: `class`
- Package: [Aspire.Microsoft.Azure.Cosmos](/reference/api/csharp/aspire.microsoft.azure.cosmos.md)
- Version: `13.4.0`
- Namespace: `Microsoft.Extensions.Hosting`
- Target framework: `net10.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Components/Aspire.Microsoft.Azure.Cosmos/AspireMicrosoftAzureCosmosExtensions.cs)

Azure Cosmos DB extension

## Definition

```csharp
namespace Microsoft.Extensions.Hosting;

public static class AspireMicrosoftAzureCosmosExtensions
{
    // ...
}
```

## Methods

- [AddAzureCosmosClient(IHostApplicationBuilder, string, Action<MicrosoftAzureCosmosSettings>, Action<CosmosClientOptions>)](/reference/api/csharp/aspire.microsoft.azure.cosmos/aspiremicrosoftazurecosmosextensions/methods.md#addazurecosmosclient-ihostapplicationbuilder-string-action-microsoftazurecosmossettings-action-cosmosclientoptions) `extension` -- Registers `Cosmos.CosmosClient` as a singleton in the services provided by the `builder`. Configures logging and telemetry for the `Cosmos.CosmosClient`.
- [AddAzureCosmosContainer(IHostApplicationBuilder, string, Action<MicrosoftAzureCosmosSettings>, Action<CosmosClientOptions>)](/reference/api/csharp/aspire.microsoft.azure.cosmos/aspiremicrosoftazurecosmosextensions/methods.md#addazurecosmoscontainer-ihostapplicationbuilder-string-action-microsoftazurecosmossettings-action-cosmosclientoptions) `extension` -- Registers the `Cosmos.Container` as a singleton in the services provided by the `builder`.
- [AddAzureCosmosDatabase(IHostApplicationBuilder, string, Action<MicrosoftAzureCosmosSettings>, Action<CosmosClientOptions>)](/reference/api/csharp/aspire.microsoft.azure.cosmos/aspiremicrosoftazurecosmosextensions/methods.md#addazurecosmosdatabase-ihostapplicationbuilder-string-action-microsoftazurecosmossettings-action-cosmosclientoptions) : [CosmosDatabaseBuilder](/reference/api/csharp/aspire.microsoft.azure.cosmos/cosmosdatabasebuilder.md) `extension` -- Registers the `Cosmos.Database` as a singleton the services provided by the `builder` and returns a [CosmosDatabaseBuilder](/reference/api/csharp/aspire.microsoft.azure.cosmos/cosmosdatabasebuilder.md) to support chaining multiple container registrations against the same database.
- [AddKeyedAzureCosmosClient(IHostApplicationBuilder, string, Action<MicrosoftAzureCosmosSettings>, Action<CosmosClientOptions>)](/reference/api/csharp/aspire.microsoft.azure.cosmos/aspiremicrosoftazurecosmosextensions/methods.md#addkeyedazurecosmosclient-ihostapplicationbuilder-string-action-microsoftazurecosmossettings-action-cosmosclientoptions) `extension` -- Registers the `Cosmos.CosmosClient` as a singleton for given `name` in the services provided by the `builder`. Configures logging and telemetry for the `Cosmos.CosmosClient`.
- [AddKeyedAzureCosmosContainer(IHostApplicationBuilder, string, Action<MicrosoftAzureCosmosSettings>, Action<CosmosClientOptions>)](/reference/api/csharp/aspire.microsoft.azure.cosmos/aspiremicrosoftazurecosmosextensions/methods.md#addkeyedazurecosmoscontainer-ihostapplicationbuilder-string-action-microsoftazurecosmossettings-action-cosmosclientoptions) `extension` -- Registers the `Cosmos.Container` as a singleton for given `name` in the services provided by the `builder`.
- [AddKeyedAzureCosmosDatabase(IHostApplicationBuilder, string, Action<MicrosoftAzureCosmosSettings>, Action<CosmosClientOptions>)](/reference/api/csharp/aspire.microsoft.azure.cosmos/aspiremicrosoftazurecosmosextensions/methods.md#addkeyedazurecosmosdatabase-ihostapplicationbuilder-string-action-microsoftazurecosmossettings-action-cosmosclientoptions) : [CosmosDatabaseBuilder](/reference/api/csharp/aspire.microsoft.azure.cosmos/cosmosdatabasebuilder.md) `extension` -- Registers the `Cosmos.Database` as a singleton for given `name` in the services provided by the `builder` and returns a [CosmosDatabaseBuilder](/reference/api/csharp/aspire.microsoft.azure.cosmos/cosmosdatabasebuilder.md) to support chaining multiple container registrations against the same database.
