Skip to content

CosmosDB Components should allow for CosmosClientOptions to be configured via IConfiguration #667

Description

@eerhardt

With #359, we added CosmosDB Components. ComosDB follows the same pattern as other Azure clients - it has XXXClient and XXXClientOptions objects.

The other Azure components allow for the XXXClientOptions object to be bound to IConfiguration, so users can tweak their settings without rebuilding/redeploying the app.

We should enable the same behavior in the CosmosDB components.

Activity

  1. added
    area-integrations
    on Nov 2, 2023
  2. added this to the milestone on Nov 2, 2023
  3. removed this from the milestone on Nov 13, 2023
  4. davidfowl commented on Jan 27, 2024

    @davidfowl
    Collaborator

    Do we still want to do this?

  5. eerhardt commented on Jan 29, 2024

    @eerhardt
    MemberAuthor

    Do we still want to do this?

    I think so. It should be consistent with the other Azure components.

  6. eerhardt commented on Feb 26, 2024

    @eerhardt
    MemberAuthor

    Kevin Pilch (@Pilchie) - is this something your team plans on implementing?

  7. modified the milestones: preview TBD (but in 8.0), on Feb 26, 2024
  8. modified the milestones: , preview 6 (Apr) on Mar 4, 2024
  9. modified the milestones: preview 6 (Apr), on Apr 1, 2024
  10. eerhardt commented on Apr 18, 2024

    @eerhardt
    MemberAuthor

    Debdatta Kunda (@kundadebdatta) - can I assign this issue to you?

  11. 6 remaining items

  12. AdamDotNet commented on May 21, 2025

    @AdamDotNet
    Contributor

    Eric Erhardt (@eerhardt)

    Might I suggest adding an overload/support for passing IServiceProvider when creating CosmosClientOptions as well?

    From

    public static void AddAzureCosmosClient(
        this IHostApplicationBuilder builder,
        string connectionName,
        Action<MicrosoftAzureCosmosSettings> configureSettings = null,
    ->    Action<CosmosClientOptions> configureClientOptions = null)

    To

    public static void AddAzureCosmosClient(
        this IHostApplicationBuilder builder,
        string connectionName,
        Action<MicrosoftAzureCosmosSettings> configureSettings = null,
    ->    Action<IServiceProvider, CosmosClientOptions> configureClientOptions = null)

    The benefit would be using the DI container to resolve RequestHandler instances that may require container services to instantiate as part of calling clientOptions.CustomHanndlers.Add(...);

  13. eerhardt commented on May 23, 2025

    @eerhardt
    MemberAuthor

    Might I suggest adding an overload/support for passing IServiceProvider when creating CosmosClientOptions as well?

    Yes, that is a good idea. Other Azure integrations get this for free because they integrate with Microsoft.Extensions.Azure, but CosmosDB's client library doesn't yet. So we would need an explicit action that takes an IServiceProvider.

  14. msivers commented on Jun 13, 2025

    @msivers

    Eric Erhardt (@eerhardt) / David Fowler (@davidfowl) / Debdatta Kunda (@kundadebdatta) is this going to be worked on?... Feels like an important capability that is missing?

  15. davidfowl commented on Jun 13, 2025

    @davidfowl
    Collaborator

    We’re not proactively prioritizing integration specific features, but feel free to submit a PR!

  16. maddymontaquila commented on May 14, 2026

    @maddymontaquila
    Collaborator

    Implemented as part of the Aspire.Microsoft.Azure.Cosmos component. The component includes a MicrosoftAzureCosmosSettings class that binds to configuration under the Aspire:Microsoft:Azure:Cosmos key (via [ConfigurationSchema] attribute), allowing CosmosClientOptions-equivalent settings to be configured through appsettings.json or environment variables. The AddAzureCosmosClient APIs also accept a configureClientOptions: Action<CosmosClientOptions> parameter for in-code customization.

  17. davidfowl commented on May 14, 2026

    @davidfowl
    Collaborator

    Reopening after reviewing the recent bulk closure. The close comment appears to cite work that does not fully address this issue, so this should remain open for normal triage.

  18. AdamDotNet commented on Aug 13, 2026

    @AdamDotNet
    Contributor

    We’re not proactively prioritizing integration specific features, but feel free to submit a PR!

    David Fowler (@davidfowl) Eric Erhardt (@eerhardt) created a PR for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-integrationsazureazure-cosmosdb

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions