Add new Cosmos DB modeling features: hierarchical partitioning, computed properties, and enhanced change feed
This PR implements support for the latest Azure Cosmos DB modeling features, adding a new database version (V5) that showcases advanced capabilities for modern NoSQL applications.
New Features Added
🚀 Hierarchical Partitioning
Demonstrates regional partitioning strategies that enable efficient geo-distributed queries while maintaining data locality. The V5 customer and sales order containers use /region as the partition key, allowing for:
- Efficient single-partition queries within regions
- Cross-regional analytics and comparisons
- Reduced RU consumption for common access patterns
⚡ Computed Properties
Educational implementation showing how computed properties automatically calculate and index derived values:
- Customer:
fullName,yearCreated - Product:
priceRange,discountedPrice - Sales Order:
orderMonth,totalValue
Benefits include automatic indexing, consistent calculations, and improved query performance.
📊 Enhanced Change Feed
Advanced change feed processor (AdvancedChangeFeed.cs) that demonstrates comprehensive operation tracking:
- Enhanced change detection with detailed logging
- Business rules processing examples
- Customer engagement scoring
- Regional analytics updates
🌍 Cross-Region Query Optimization
New demo functions that compare query performance across different partition strategies, showing the benefits of hierarchical partitioning for geo-distributed applications.
Implementation Details
Infrastructure: Updated Bicep templates to include database-v5 with optimized container configurations for regional partitioning.
Data Models: New V5 models (CustomerV5, ProductV5, SalesOrderV5) that support advanced partitioning strategies and computed property concepts.
Interactive Demos: Four new menu options (l, m, n, o) that provide hands-on experience with:
- Hierarchical partitioning benefits
- Computed property usage patterns
- Advanced change feed processing
- Cross-region query optimization
Sample Data: Realistic V5 dataset with customers across North America, Europe, and Asia Pacific regions, demonstrating global distribution patterns.
Educational Value
Each demo includes comprehensive explanations, real-world use cases, and migration guidance. The implementation serves as both a working example and educational resource for developers learning modern NoSQL data modeling patterns.
Documentation: Complete feature guide (docs/V5-FEATURES.md) with examples, best practices, and migration considerations from V4 to V5.
This enhancement makes CosmicWorks a comprehensive showcase of Cosmos DB evolution from basic relational patterns (V1) through advanced NoSQL optimizations (V5), perfect for developers transitioning to modern distributed database architectures.
Fixes #49.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.
@markjbrown 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.
I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.
@copilot can you create a new local branch and put the changes from this pull request into it?
@copilot can you create a new local branch and put the changes from this pull request into it?
I'm currently working on branch copilot/fix-49 which contains the PR changes (commits 16e2aa7 and 44e3cee).
Could you clarify what you'd like me to do? I can:
- Create a new local branch from the current state (but I cannot push it to remote)
- Continue working on the current branch
copilot/fix-49
Note: I'm limited to pushing changes to the current PR branch. If you need the changes in a different branch, you may need to create it manually or let me know the specific branch name and I can explain the git commands needed.
@copilot ok, makes sense. Can you open that view I just had here locally that allowed me to see all the changes in this PR?
@copilot ok, makes sense. Can you open that view I just had here locally that allowed me to see all the changes in this PR?
I can't directly open a UI view, but here are git commands you can run locally to review all PR changes:
Summary of changed files:
git diff --stat 0d11c15..HEAD
View all changes with full diff:
git diff 0d11c15..HEAD
View changes for a specific file:
git diff 0d11c15..HEAD -- path/to/file
See commit-by-commit changes:
git log -p 0d11c15..HEAD
The PR adds 10 files with 1,320 insertions including V5 models, sample data, documentation, infrastructure updates, and demo functions.