azure-cosmosdb

Design partition keys and SDK data access patterns for Azure Cosmos DB.

1|Updated Feb 26, 2026
One-click install
npx skills add https://github.com/aberrantCode/llm_skills --skill azure-cosmosdb-aberrantcode
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: azure-cosmosdb
Source: https://github.com/aberrantCode/llm_skills/tree/main/claude/skills/azure-cosmosdb
Command: npx skills add https://github.com/aberrantCode/llm_skills --skill azure-cosmosdb-aberrantcode

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps developers and architects design partition keys, choose appropriate consistency levels, and implement SDK patterns so Azure Cosmos DB workloads are performant, cost-efficient, and reliably processed via the change feed.

Core Features & Use Cases

  • Partition key design: guidance for high-cardinality keys, hierarchical keys for multi-tenant scenarios, and anti-patterns to avoid hot partitions.
  • Consistency & throughput: tradeoffs between Strong, Bounded Staleness, Session, Consistent Prefix, and Eventual consistency and strategies for provisioned, autoscale, and serverless throughput.
  • SDK patterns (TypeScript & Python): examples for client initialization, point reads, queries, patch/replace updates, optimistic concurrency with ETags, transactional batches, and bulk imports.
  • Change feed processing: iterator and processor patterns, lease containers, and production considerations for processing and retrying.
  • Indexing and cost optimization: indexing policy examples, TTL, and strategies to reduce RU costs.
  • Use Case: build a scalable orders service where userId is the partition key, process order events via the change feed, and minimize cross-partition queries and RU spend.

Quick Start

Show me how to create a Cosmos DB container with partition key /userId and provide a TypeScript example for point reads and change feed processing.

Frequently Asked Questions about azure-cosmosdb

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I design an Azure Cosmos DB partition key to avoid hot partitions?

Choose Cosmos DB partition keys with high cardinality or hierarchical composite keys for multi-tenant workloads to distribute RU consumption evenly. Avoiding low-cardinality keys prevents hot partitions and request throttling.

How does the Cosmos DB change feed work for processing order events?

The Cosmos DB change feed provides a persistent, ordered log of document modifications. You process order events using iterator or processor patterns with a lease container to manage state and handle retries across partitions.

What are the tradeoffs between Cosmos DB consistency levels for NoSQL workloads?

Cosmos DB consistency tradeoffs range from Strong for guaranteed recency to Eventual for maximum throughput. Bounded Staleness, Session, and Consistent Prefix offer intermediate latency and availability guarantees for NoSQL workloads.

Can I use TypeScript and Python SDKs for Cosmos DB transactional batches and bulk imports?

Yes, both TypeScript and Python SDKs support Cosmos DB transactional batches and bulk imports. They provide client initialization, point reads, patch updates, optimistic concurrency via ETags, and bulk processing patterns.

What is the best way to reduce RU costs and optimize indexing in Azure Cosmos DB?

Reduce Cosmos DB RU costs by applying targeted indexing policies, setting TTL for automatic document expiry, and minimizing cross-partition queries. Selecting provisioned, autoscale, or serverless throughput further optimizes spend.

When should I not use a cross-partition query in Azure Cosmos DB?

Avoid Cosmos DB cross-partition queries when point reads suffice, as fan-out queries consume more RUs and increase latency. Restrict queries to a single partition using the partition key to maximize efficiency and reduce RU spend.