Skip to content

feat(cosmos): support hierarchical partition keys - #10926

Closed
ScottArbeit wants to merge 3 commits into
dotnet:mainfrom
ScottArbeit:codex/cosmos-hierarchical-partition-keys
Closed

feat(cosmos): support hierarchical partition keys#10926
ScottArbeit wants to merge 3 commits into
dotnet:mainfrom
ScottArbeit:codex/cosmos-hierarchical-partition-keys

Conversation

@ScottArbeit

@ScottArbeit ScottArbeit commented Aug 30, 2026

Copy link
Copy Markdown

Closes #9899

Problem

Cosmos grain storage models each record with a single string partition key, so applications cannot use Cosmos DB hierarchical partition keys for tenant-aware distribution without replacing the storage provider.

Solution

  • Add an ordered document-key contract that supports one, two, or three string partition-key components while preserving existing IDocumentIdProvider implementations.
  • Persist the selected components in fixed fields and use the same resolved values for Cosmos point operations.
  • Validate configured partition-key paths against existing containers, including legacy /GrainType compatibility for the built-in provider.
  • Document HPK configuration with compiled snippets and focused compatibility coverage.

Rationale

Keeping document identity and ordered partition-key values together prevents request keys from drifting from persisted fields. The level count makes HPK opt-in, preserves existing single-key behavior, and rejects mismatched container definitions during startup.

Microsoft Reviewers: Open in CodeFlow

@ScottArbeit

Copy link
Copy Markdown
Author

Sorry, didn't mean to dump this work-in-progress here yet. 😳 I'm going to close it for now and check in about doing this correctly, I don't want to be rude.

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.

Support hierarchical partition keys in Cosmos DB grain storage

1 participant