Add UseCosmosDbPersistence overload for DI-registered CosmosClient - #1439
Closed
danielgerlag wants to merge 1 commit into
Closed
Add UseCosmosDbPersistence overload for DI-registered CosmosClient#1439danielgerlag wants to merge 1 commit into
danielgerlag wants to merge 1 commit into
Conversation
Resolve CosmosClient from the service collection so apps that already register a client can reuse it. Same registration pattern as the other Cosmos overloads. Credits mbadev62; closes #1424; replacement for #1421 which conflicts with Azure Table persistence on master. Co-authored-by: Daniel Gerlag <danielgerlag@users.noreply.github.com>
danielgerlag
added a commit
that referenced
this pull request
Sep 7, 2026
* Bump version to 3.21.0 Ship the host-startup Activity NRE fix (#1438), PostgreSQL Delay timezone fix (#1425 / #1440), and Cosmos DI client overload (#1439 / #1424). Co-authored-by: Daniel Gerlag <danielgerlag@users.noreply.github.com> * Fix EF DateTime timezone mismatch hanging Delay on PostgreSQL Same change as #1425 / #1440. Included here so 3.21.0 ships the fix even if the Copilot PR remains blocked by the coding-agent review rule. Co-authored-by: Daniel Gerlag <danielgerlag@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Daniel Gerlag <danielgerlag@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
UseCosmosDbPersistence(databaseId, cosmosDbStorageOptions)that resolvesCosmosClientfrom DI viasp.GetService<CosmosClient>(), matching the existing Cosmos overload style.masterso Azure Table persistence methods from later commits are kept.Describe the change
Applications that already register
CosmosClientas a singleton can now configure Cosmos persistence without a connection string, an early-constructed client, orBuildServiceProvider().Describe your implementation or design
New overload copies the existing Cosmos registration (factory, provisioner, purger, persistence provider) and constructs
CosmosClientFactoryfrom the DI-registeredCosmosClient. UsesGetServiceto match the rest of this file.Tests
No new tests. Registration matches the existing overloads.
Breaking change
No.
Additional context
#1421 from mbadev62 had the same change but conflicts with Azure Table persistence methods added to this file after the branch was cut. Cannot push to the contributor fork, so this maintainer branch applies the same overload on current master.
Credits: @mbadev62
Closes #1424
Supersedes #1421