AspireMicrosoftAzureCosmosExtensions.AddKeyedAzureCosmosDatabase Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Registers the Database as a singleton for given name
in 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 AddKeyedAzureCosmosDatabase(this Microsoft.Extensions.Hosting.IHostApplicationBuilder builder, string name, Action<Aspire.Microsoft.Azure.Cosmos.MicrosoftAzureCosmosSettings>? configureSettings = default, Action<Microsoft.Azure.Cosmos.CosmosClientOptions>? configureClientOptions = default);
static member AddKeyedAzureCosmosDatabase : Microsoft.Extensions.Hosting.IHostApplicationBuilder * string * Action<Aspire.Microsoft.Azure.Cosmos.MicrosoftAzureCosmosSettings> * Action<Microsoft.Azure.Cosmos.CosmosClientOptions> -> Aspire.Microsoft.Azure.Cosmos.CosmosDatabaseBuilder
<Extension()>
Public Function AddKeyedAzureCosmosDatabase (builder As IHostApplicationBuilder, name 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.
- name
- String
The name of the component, which is used as the ServiceKey of the service and also to retrieve the connection string from the ConnectionStrings configuration section.
- 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.