Demo materials for Azure Cosmos DB Conf 2026.
Every query in Azure Cosmos DB has two jobs: finding the right partitions and then identifying the right documents within them. Understanding how routing and indexing work together is the key to writing queries that are both fast and cost-efficient.
This repo supports the Cosmos DB Conf 2026 session with a live, code-first walkthrough of Azure Cosmos DB query execution and indexing behavior. The demos compare baseline and optimized query paths, show RU impact directly, and connect each optimization technique to a real multitenant e-retail workflow.
- Query fundamentals, including partition routing, indexing behavior, and reading query metrics.
- Azure Cosmos DB SQL query language features such as joins, aggregates, subqueries, and system functions.
- Index types and when to use them: range, composite, geospatial, full-text, and vector indexes.
- Index management, including indexing policies, index builds, and rebuild considerations.
- Advanced optimization techniques such as computed properties and identifying high-RU queries.
- A clear mental model for how Azure Cosmos DB queries execute.
- Practical guidance for choosing and tuning index types.
- Diagnostic techniques for finding and fixing expensive queries.
The live demo is framed as a multitenant e-retail platform where customers shop across a portfolio of outdoor brands. The walkthrough uses one shared product catalog model and compares two Cosmos DB containers:
products: same data, minimally indexed baseline for contrast.products_optimized: same data, configured for the query and search patterns covered in the session.
That contrast makes the cost and latency impact of indexing decisions visible on screen.
.
├── .env.example # Template for required environment variables
├── CosmosConf26QueryDemos.sln # Solution file for the demo apps
├── DEMO_SCRIPT.md # Presenter script for the live walkthrough
├── README.md # Project overview and setup instructions
├── SLIDE_OUTLINE.md # Slide-by-slide outline for the session
├── data/ # Sample catalog data and generation helpers
│ ├── generate_products.py # Script to generate deterministic demo products
│ └── products.json # Product dataset loaded into both containers
└── src/ # .NET source projects for setup and demo execution
├── DemoCommon/ # Shared settings, models, policies, and scenario definitions
├── DemoRunner/ # Data loading and scenario execution console app
└── DemoSetup/ # Cosmos DB setup and container deployment console app
DEMO_SCRIPT.md: presenter script for the live session.SLIDE_OUTLINE.md: one-page slide outline aligned to the demo flow.src/DemoSetup: validates Azure configuration and applies the Cosmos DB database and container setup.src/DemoRunner: seeds sample data and runs the step-by-step demo sections with diagnostics for every query.data/products.json: generated sample dataset used for both containers. Thegenerate-datacommand defaults to 1,000 total products unless you pass a different count.
Copy .env.example to .env and set the Azure resource values.
The setup flow expects an existing Cosmos DB account with the EnableNoSQLVectorSearch and EnableNoSQLFullTextSearch capabilities enabled.
Authentication uses DefaultAzureCredential, so sign in with Azure CLI, Visual Studio, or another supported Entra ID flow before running the commands.
The setup flow configures both demo containers with dedicated autoscale throughput and a maximum of 5,000 RU/s each.
Build the solution:
dotnet build CosmosConf26QueryDemos.slnApply the demo database and container setup:
dotnet run --project src/DemoSetupSeed both containers with the same logical dataset:
dotnet run --project src/DemoRunner -- load
dotnet run --project src/DemoRunner -- load data/products.jsonGenerate product data with LLM-authored names and descriptions (optional, regenerates data/products.json by default. This requires AZURE_OPENAI_CHAT_DEPLOYMENT_NAME to be specified, defaults to gpt-5.4-nano, generates 1,000 total products unless you pass a count, and can write to a custom output file path):
dotnet run --project src/DemoRunner -- generate-data
dotnet run --project src/DemoRunner -- generate-data 3000
dotnet run --project src/DemoRunner -- generate-data 3000 data/products-3000.json
dotnet run --project src/DemoRunner -- generate-data data/products-custom.jsonRun one section at a time:
dotnet run --project src/DemoRunner -- demo basic
dotnet run --project src/DemoRunner -- demo composite
dotnet run --project src/DemoRunner -- demo arrays
dotnet run --project src/DemoRunner -- demo computed-properties
dotnet run --project src/DemoRunner -- demo geospatial
dotnet run --project src/DemoRunner -- demo vector
dotnet run --project src/DemoRunner -- demo full-text
dotnet run --project src/DemoRunner -- demo hybridRun the full demo sequence:
dotnet run --project src/DemoRunner -- demo allOptional final cleanup step to delete the demo containers and database:
dotnet run --project src/DemoSetup -- cleanupThe runner prints a query overview once per scenario, then for each execution prints Summary, an ASCII Query Metrics table, pretty-printed Index Metrics, Interpretation, and Sample Rows. After both runs, it prints a side-by-side comparison table with Server Time, RU Charge, and percentage difference.
Most scenarios compare products against products_optimized. The computed-properties, vector, and hybrid demos intentionally run both queries on products_optimized to isolate the optimization itself.