feat(cosmos): add configuration support for grain storage - #10326
Merged
Merged
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: e82f060d-d09b-42f9-8b0f-34da38b386fa
Contributor
There was a problem hiding this comment.
Pull request overview
Adds configuration-based provider wiring for Cosmos grain storage in Orleans, enabling options binding from IConfiguration and DI-based selection of a keyed IDocumentIdProvider without reflection/type-name activation.
Changes:
- Introduces
CosmosGrainStorageProviderBuilderregistered as theAzureCosmosDBGrainStorageprovider, bindingCosmosGrainStorageOptionsfrom configuration and supportingServiceKey/ConnectionName/ConnectionStringCosmos client selection. - Adds support for
DocumentIdProviderKeyto alias an application-registered keyedIDocumentIdProviderto the storage provider’s name. - Adds/extends tests to validate keyed provider resolution, DI constructor injection, and named options binding.
Show a summary per file
| File | Description |
|---|---|
| test/Extensions/Orleans.Cosmos.Tests/CosmosHostingExtensionsTests.cs | Adds coverage for config-driven DocumentIdProviderKey resolution and named options binding. |
| src/Azure/Orleans.Persistence.Cosmos/CosmosGrainStorageProviderBuilder.cs | New provider builder registering AzureCosmosDB grain storage and binding/deriving options from IConfiguration. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 1
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: cc82c70d-1c36-4b98-92d4-d9e0c2bce556
Contributor
There was a problem hiding this comment.
Copilot's findings
Suppressed comments (1)
src/Azure/Orleans.Persistence.Cosmos/CosmosGrainStorageProviderBuilder.cs:23
- If
DocumentIdProviderKeyis set to the same value as the storage provider name (name), this registration becomes self-referential and will trigger a circular dependency when resolving the keyedIDocumentIdProvider(keyed byname). Consider failing fast with a clear error (or skipping the aliasing) when the keys are equal.
var documentIdProviderKey = configurationSection["DocumentIdProviderKey"];
if (!string.IsNullOrEmpty(documentIdProviderKey))
{
builder.Services.AddKeyedSingleton<IDocumentIdProvider>(
name,
(services, _) => services.GetRequiredKeyedService<IDocumentIdProvider>(documentIdProviderKey));
}
- Files reviewed: 2/2 changed files
- Comments generated: 0 new
This was referenced Aug 28, 2026
Merged
This was referenced Sep 1, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Follow-up to #8699.
Adds
IConfigurationsupport for Cosmos grain storage and addresses the document ID provider configuration feedback.AzureCosmosDBas aGrainStorageprovider.CosmosGrainStorageOptionsfrom the provider configuration section.ServiceKey,ConnectionName, andConnectionStringfor the Cosmos client.DocumentIdProviderKey, resolving an application-registered keyedIDocumentIdProviderthrough dependency injection and aliasing it to the storage provider name.CosmosGrainStorageOptionsand avoids reflection/type-name activation.Tests cover keyed provider resolution, constructor dependency injection, and named options binding on net8.0 and net10.0.
Microsoft Reviewers: Open in CodeFlow