Share via


AspireMicrosoftAzureCosmosExtensions.AddAzureCosmosDatabase Method

Definition

Registers the Database as a singleton the services provided by the builder and returns a CosmosDatabaseBuilder to support chaining multiple container registrations against the same database.

public static Aspire.Microsoft.Azure.Cosmos.CosmosDatabaseBuilder AddAzureCosmosDatabase(this Microsoft.Extensions.Hosting.IHostApplicationBuilder builder, string connectionName, Action<Aspire.Microsoft.Azure.Cosmos.MicrosoftAzureCosmosSettings>? configureSettings = default, Action<Microsoft.Azure.Cosmos.CosmosClientOptions>? configureClientOptions = default);
static member AddAzureCosmosDatabase : Microsoft.Extensions.Hosting.IHostApplicationBuilder * string * Action<Aspire.Microsoft.Azure.Cosmos.MicrosoftAzureCosmosSettings> * Action<Microsoft.Azure.Cosmos.CosmosClientOptions> -> Aspire.Microsoft.Azure.Cosmos.CosmosDatabaseBuilder
<Extension()>
Public Function AddAzureCosmosDatabase (builder As IHostApplicationBuilder, connectionName As String, Optional configureSettings As Action(Of MicrosoftAzureCosmosSettings) = Nothing, Optional configureClientOptions As Action(Of CosmosClientOptions) = Nothing) As CosmosDatabaseBuilder

Parameters

builder
IHostApplicationBuilder

The IHostApplicationBuilder to read config from and add services to.

connectionName
String

The connection name to use to find a connection string.

configureSettings
Action<MicrosoftAzureCosmosSettings>

An optional method that can be used for customizing the MicrosoftAzureCosmosSettings. It's invoked after the settings are read from the configuration.

configureClientOptions
Action<CosmosClientOptions>

An optional method that can be used for customizing the CosmosClientOptions.

Returns

Exceptions

If required ConnectionString is not provided in configuration section

Remarks

Reads the configuration from "Aspire:Microsoft:Azure:Cosmos:{name}" section.

Applies to