microsoft / microsoft/aspire

Add 'AddCosmosDbContextFactory' to CosmosDb EF integration

Open
#18,871 1 comment 0 reactions 0 assignees View on GitHub
area-integrations triage:bot-seen
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

The 'AddCosmosDbContext' method wraps a nice amount of simplification for, i.e. takes care of whether you're using a connetion string/key or well configured Azure token credentials (and it's resilient to changes if you where to flip from one to the other).

If you want to add a DbContextFactory e.g. 'AddPooledDbContextFactory', it seems like you're then on your own with this stuff, and you end up pulling internal code out of the aspire integration package (e.g. 'AzureCredentialHelper).

It would be useful to have a similar 'AddCosmosDbContextFactory' (and an equivalent for other databases like SQL), or just have the factory service registration baked in for free with the 'AddCosmosDbContext'.

### Describe the solution you'd like

Out of the box 'AddCosmosDbContextFactory' or factory registration integrated into 'AddCosmosDbContext'

### Additional context

It would also be helpful to have something from an aspire library/integration that made what 'AzureCredentialHelper' produces public/available, to get the opinionated framework's 'TokenCredential' rather than figuring it out yourself. It's fairly easy to use 'DefaultAzureCredential' but find you get telemetry/app insights noise and exceptions where it tries its various things in production, so end up looking at what aspire does.

Contributor guide

Open the contributing guide

Research direction

Start by locating the existing AddCosmosDbContext entry point and the AzureCredentialHelper used by the Aspire integration. Compare the requested factory registration with AddPooledDbContextFactory and determine whether the scope is a new AddCosmosDbContextFactory or factory support within AddCosmosDbContext. Done means the chosen registration preserves the existing credential handling and has coverage for the supported behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.