Skip to content

Add UseCosmosDbPersistence overload for DI-registered CosmosClient - #1439

Closed
danielgerlag wants to merge 1 commit into
masterfrom
cursor/cosmos-di-client-overload-04a9
Closed

Add UseCosmosDbPersistence overload for DI-registered CosmosClient#1439
danielgerlag wants to merge 1 commit into
masterfrom
cursor/cosmos-di-client-overload-04a9

Conversation

@danielgerlag

Copy link
Copy Markdown
Owner

Summary

Describe the change
Applications that already register CosmosClient as a singleton can now configure Cosmos persistence without a connection string, an early-constructed client, or BuildServiceProvider().

Describe your implementation or design
New overload copies the existing Cosmos registration (factory, provisioner, purger, persistence provider) and constructs CosmosClientFactory from the DI-registered CosmosClient. Uses GetService to 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

Open in Web Open in Cursor 

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>
@cursor

cursor Bot commented Sep 6, 2026

Copy link
Copy Markdown

Ready to squash-merge. This is the #1421 replacement on current master (Azure Table methods kept). Same DI-registered CosmosClient overload as mbadev62; closes #1424.

Blocked on a code-owner approving review (or an admin merge). Please squash-merge when convenient so #1441 (3.21.0) can follow.

@cursor

cursor Bot commented Sep 6, 2026

Copy link
Copy Markdown

#1421 is now MERGEABLE (conflict resolved on the contributor fork; clean 17-line DI overload). Prefer squash-merging #1421 so mbadev62 keeps authorship and #1424 auto-closes. This maintainer PR can be closed once #1421 lands.

cursor Bot pushed a commit that referenced this pull request Sep 6, 2026
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>
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UseCosmosDbPersistence() should support factory delegate to resolve CosmosClient from DI container

2 participants