Skip to content
DocsTry Aspire
DocsTry

AspireMicrosoftAzureCosmosExtensions Methods

ClassMethods6 members
Azure Cosmos DB extension
AddAzureCosmosClient(IHostApplicationBuilder, string, Action<MicrosoftAzureCosmosSettings>, Action<CosmosClientOptions>)Section titled 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.
public static class AspireMicrosoftAzureCosmosExtensions
{
public static void AddAzureCosmosClient(
this IHostApplicationBuilder builder,
string connectionName,
Action<MicrosoftAzureCosmosSettings>? configureSettings = null,
Action<CosmosClientOptions>? configureClientOptions = null)
{
// ...
}
}
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder to read config from and add services to.
connectionNamestringThe connection name to use to find a connection string.
configureSettingsAction<MicrosoftAzureCosmosSettings>optionalAn optional method that can be used for customizing the MicrosoftAzureCosmosSettings. It's invoked after the settings are read from the configuration.
configureClientOptionsAction<CosmosClientOptions>optionalAn optional method that can be used for customizing the Cosmos.CosmosClientOptions.
InvalidOperationExceptionIf required ConnectionString is not provided in configuration section
Reads the configuration from "Aspire:Microsoft:Azure:Cosmos" section.
AddAzureCosmosContainer(IHostApplicationBuilder, string, Action<MicrosoftAzureCosmosSettings>, Action<CosmosClientOptions>)Section titled AddAzureCosmosContainer(IHostApplicationBuilder, string, Action<MicrosoftAzureCosmosSettings>, Action<CosmosClientOptions>)extension
Registers the Cosmos.Container as a singleton in the services provided by the builder.
public static class AspireMicrosoftAzureCosmosExtensions
{
public static void AddAzureCosmosContainer(
this IHostApplicationBuilder builder,
string connectionName,
Action<MicrosoftAzureCosmosSettings>? configureSettings = null,
Action<CosmosClientOptions>? configureClientOptions = null)
{
// ...
}
}
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder to read config from and add services to.
connectionNamestringThe connection name to use to find a connection string.
configureSettingsAction<MicrosoftAzureCosmosSettings>optionalAn optional method that can be used for customizing the MicrosoftAzureCosmosSettings. It's invoked after the settings are read from the configuration.
configureClientOptionsAction<CosmosClientOptions>optionalAn optional method that can be used for customizing the Cosmos.CosmosClientOptions.
InvalidOperationExceptionIf required ConnectionString is not provided in configuration section
Reads the configuration from "Aspire:Microsoft:Azure:Cosmos" section.
AddAzureCosmosDatabase(IHostApplicationBuilder, string, Action<MicrosoftAzureCosmosSettings>, Action<CosmosClientOptions>)Section titled AddAzureCosmosDatabase(IHostApplicationBuilder, string, Action<MicrosoftAzureCosmosSettings>, Action<CosmosClientOptions>)extensionCosmosDatabaseBuilder
Registers the Cosmos.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 class AspireMicrosoftAzureCosmosExtensions
{
public static CosmosDatabaseBuilder AddAzureCosmosDatabase(
this IHostApplicationBuilder builder,
string connectionName,
Action<MicrosoftAzureCosmosSettings>? configureSettings = null,
Action<CosmosClientOptions>? configureClientOptions = null)
{
// ...
}
}
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder to read config from and add services to.
connectionNamestringThe connection name to use to find a connection string.
configureSettingsAction<MicrosoftAzureCosmosSettings>optionalAn optional method that can be used for customizing the MicrosoftAzureCosmosSettings. It's invoked after the settings are read from the configuration.
configureClientOptionsAction<CosmosClientOptions>optionalAn optional method that can be used for customizing the Cosmos.CosmosClientOptions.
InvalidOperationExceptionIf required ConnectionString is not provided in configuration section
Reads the configuration from "Aspire:Microsoft:Azure:Cosmos:{name}" section.
AddKeyedAzureCosmosClient(IHostApplicationBuilder, string, Action<MicrosoftAzureCosmosSettings>, Action<CosmosClientOptions>)Section titled 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.
public static class AspireMicrosoftAzureCosmosExtensions
{
public static void AddKeyedAzureCosmosClient(
this IHostApplicationBuilder builder,
string name,
Action<MicrosoftAzureCosmosSettings>? configureSettings = null,
Action<CosmosClientOptions>? configureClientOptions = null)
{
// ...
}
}
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder to read config from and add services to.
namestringThe name of the component, which is used as the ServiceDescriptor.ServiceKey of the service and also to retrieve the connection string from the ConnectionStrings configuration section.
configureSettingsAction<MicrosoftAzureCosmosSettings>optionalAn optional method that can be used for customizing the MicrosoftAzureCosmosSettings. It's invoked after the settings are read from the configuration.
configureClientOptionsAction<CosmosClientOptions>optionalAn optional method that can be used for customizing the Cosmos.CosmosClientOptions.
InvalidOperationExceptionIf required ConnectionString is not provided in configuration section
Reads the configuration from "Aspire:Microsoft:Azure:Cosmos:{name}" section.
AddKeyedAzureCosmosContainer(IHostApplicationBuilder, string, Action<MicrosoftAzureCosmosSettings>, Action<CosmosClientOptions>)Section titled 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.
public static class AspireMicrosoftAzureCosmosExtensions
{
public static void AddKeyedAzureCosmosContainer(
this IHostApplicationBuilder builder,
string name,
Action<MicrosoftAzureCosmosSettings>? configureSettings = null,
Action<CosmosClientOptions>? configureClientOptions = null)
{
// ...
}
}
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder to read config from and add services to.
namestringThe name of the component, which is used as the ServiceDescriptor.ServiceKey of the service and also to retrieve the connection string from the ConnectionStrings configuration section.
configureSettingsAction<MicrosoftAzureCosmosSettings>optionalAn optional method that can be used for customizing the MicrosoftAzureCosmosSettings. It's invoked after the settings are read from the configuration.
configureClientOptionsAction<CosmosClientOptions>optionalAn optional method that can be used for customizing the Cosmos.CosmosClientOptions.
InvalidOperationExceptionIf required ConnectionString is not provided in configuration section
Reads the configuration from "Aspire:Microsoft:Azure:Cosmos:{name}" section.
AddKeyedAzureCosmosDatabase(IHostApplicationBuilder, string, Action<MicrosoftAzureCosmosSettings>, Action<CosmosClientOptions>)Section titled AddKeyedAzureCosmosDatabase(IHostApplicationBuilder, string, Action<MicrosoftAzureCosmosSettings>, Action<CosmosClientOptions>)extensionCosmosDatabaseBuilder
Registers the Cosmos.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 class AspireMicrosoftAzureCosmosExtensions
{
public static CosmosDatabaseBuilder AddKeyedAzureCosmosDatabase(
this IHostApplicationBuilder builder,
string name,
Action<MicrosoftAzureCosmosSettings>? configureSettings = null,
Action<CosmosClientOptions>? configureClientOptions = null)
{
// ...
}
}
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder to read config from and add services to.
namestringThe name of the component, which is used as the ServiceDescriptor.ServiceKey of the service and also to retrieve the connection string from the ConnectionStrings configuration section.
configureSettingsAction<MicrosoftAzureCosmosSettings>optionalAn optional method that can be used for customizing the MicrosoftAzureCosmosSettings. It's invoked after the settings are read from the configuration.
configureClientOptionsAction<CosmosClientOptions>optionalAn optional method that can be used for customizing the Cosmos.CosmosClientOptions.
InvalidOperationExceptionIf required ConnectionString is not provided in configuration section
Reads the configuration from "Aspire:Microsoft:Azure:Cosmos:{name}" section.