Skip to article
Databases Azure Cosmos DB

Azure Cosmos DB

Azure Cosmos DB is a fully managed database service for NoSQL, relational, and vector workloads. It supports global distribution, elastic scale, multiple APIs, request-unit capacity, backup, and high availability so modern applications can store and query data without operating database servers.

Source: Microsoft Learn - Azure Cosmos DB documentation Reviewed 2026-05-30

Exam trap
Choosing a partition key from a familiar relational model instead of testing cardinality, access patterns, and tenant growth under realistic load.
Production check
Confirm the account API, write region, failover priority, backup mode, and public network access before approving production changes.
Article details and learning context
Aliases
Azure Cosmos DB, Cosmos DB, Azure Cosmos DB for NoSQL, Cosmos database, global NoSQL database, request-unit database
Difficulty
fundamentals
CLI mappings
4
Last verified
2026-05-30
Article depth
field-manual-complete

Understand the concept

In plain English

Azure Cosmos DB is a managed database for applications that need fast reads and writes, flexible data models, and scale beyond one server or region. Instead of building replication, backups, capacity controls, and distributed database operations yourself, you create an account, choose an API, model data into containers, and pay for throughput and storage. It is most useful when user experience depends on low-latency access to data such as profiles, carts, events, device records, recommendations, or application state.

Why it matters

Azure Cosmos DB matters because it can make a global application feel local when it is designed correctly, or become expensive and slow when it is treated like an ordinary relational database. Partition key choice, consistency level, RU allocation, indexing policy, and region strategy all affect user latency, failover behavior, and monthly spend. It also changes how teams think about data modeling: duplication, denormalized documents, and workload-specific containers are normal design tools. For operators, the term matters because troubleshooting a 429 throttling storm, hot partition, or regional failover requires Cosmos-specific evidence, not generic database instincts. It also anchors SLA, data-residency, and recovery conversations with product owners.

Technical context

Technically, Azure Cosmos DB sits in the data platform and data plane. An Azure Cosmos DB account defines API type, regions, consistency, backup mode, networking, keys, identity settings, and failover behavior. Databases and containers hold items, partition keys control distribution, and request units measure capacity consumed by reads, writes, and queries. Applications usually connect through SDKs, private endpoints, managed identity where supported, or keys stored in Key Vault. Azure Monitor exposes latency, throttling, storage, availability, and regional metrics.

Exam context

What to know

operator field manual with architecture, governance, CLI, and case-study depth

Compare with

Where it is used

Where you see it

  1. In the Azure portal, Azure Cosmos DB appears as an account with Data Explorer, Replicate data globally, Networking, Keys, Metrics, Backup, and diagnostic settings blades.
  2. In Azure CLI output, operators see account API type, locations, failover priorities, consistency policy, capabilities, private endpoint connections, and database or container listings during release and incident checks.
  3. In Azure Monitor, it appears through normalized RU consumption, throttled requests, latency, availability, storage, request charge, and regional health metrics during incidents for customer-facing workloads.

Common situations

  • Build globally responsive user profile, cart, session, or personalization stores where users expect low-latency reads in multiple regions.
  • Ingest high-volume IoT, telemetry, or event records that need elastic throughput, partitioned storage, and time-based retention.
  • Support flexible JSON document models when product teams change attributes faster than a relational schema can comfortably evolve.
  • Provide vector or hybrid data patterns for AI applications that need fast retrieval over operational data.
  • Run multi-tenant SaaS workloads where partitioning, RU budgets, and regional placement must be governed per workload boundary.

Illustrative Azure scenarios

These examples show how the concept can affect design and operations. They are illustrative scenarios, not customer claims.

Scenario 01 Global game profile latency stabilizes before tournament night Scenario, objectives, solution, measured impact, and takeaway.
Scenario

A multiplayer game studio had players in North America, Europe, and Japan reading profile, inventory, and match-summary data from a single regional database. Tournament nights created visible lag and angry community posts.

Goals
  • Keep profile reads under 25 milliseconds at P95 in three regions.
  • Survive a regional read outage without blocking match starts.
  • Reduce emergency database scaling during tournaments by 60 percent.
  • Give support teams evidence for throttling and regional latency issues.
Approach using Azure Cosmos DB

Architects moved player profile and inventory documents to Azure Cosmos DB for NoSQL with regions near the largest player populations. They modeled documents around player ID, separated write-heavy match events from read-heavy profile data, and used session consistency so users saw their own recent changes without forcing global strong consistency. Autoscale throughput handled tournament spikes, while Azure Monitor tracked normalized RU consumption, 429 responses, latency, and availability by region. Private endpoints restricted database access to the game services subnet, and Key Vault stored fallback keys during the migration. A runbook described how to test regional failover, verify SDK preferred regions, and replay failed writes from a queue.

Potential outcomes
  • P95 profile reads dropped from 118 milliseconds to 19 milliseconds.
  • Tournament-night throttling fell by 74 percent after partition and RU tuning.
  • A planned regional failover test completed with no blocked match starts.
  • Support could identify hot tenants and regional latency in under five minutes.
What to learn

Azure Cosmos DB is powerful when global latency, partition design, and operational evidence are designed as one system.

Scenario 02 Fleet telemetry stops overwhelming nightly maintenance reports Scenario, objectives, solution, measured impact, and takeaway.
Scenario

A marine logistics operator collected sensor records from refrigerated containers on ships and at ports. The old database could not keep up with bursty satellite uploads after vessels came back online.

Goals
  • Ingest delayed telemetry bursts without dropping temperature alerts.
  • Keep the last 180 days queryable for compliance investigations.
  • Separate high-volume raw events from curated incident records.
  • Cut manual database cleanup effort by at least half.
Approach using Azure Cosmos DB

The platform team used Azure Cosmos DB containers for raw telemetry, container state, and exception records. Events were partitioned by container ID and time bucket so delayed uploads spread across logical partitions instead of hammering one key. Time to live removed raw records after the compliance window, while curated exceptions stayed in a separate container for longer retention. Azure Functions buffered messages from Event Hubs and wrote idempotently to Cosmos DB. Operators used CLI and dashboards to confirm throughput mode, partition key paths, indexing policy, and RU spikes after ships docked. Diagnostic logs fed a workbook showing ingestion lag, throttling, and the containers most likely to require tuning.

Potential outcomes
  • Burst ingestion completed 63 percent faster after partition redesign.
  • Temperature-alert loss during reconnection windows fell to zero.
  • Manual cleanup jobs were retired, saving 22 operator hours per month.
  • Compliance searches across 180 days finished in minutes instead of overnight.
What to learn

Azure Cosmos DB helps event-heavy systems when retention, partitioning, and burst capacity are engineered around the real arrival pattern.

Scenario 03 Education platform isolates tenant growth without rebuilding the app Scenario, objectives, solution, measured impact, and takeaway.
Scenario

An online learning platform stored course progress for school districts with very different enrollment sizes. Large districts created hot spots that slowed smaller tenants during exams.

Goals
  • Protect small tenants from large-district traffic spikes.
  • Keep exam progress writes under 50 milliseconds at P95.
  • Provide tenant-level cost and throttling visibility.
  • Avoid a full relational schema redesign during the semester.
Approach using Azure Cosmos DB

Engineers redesigned the Azure Cosmos DB model around tenant ID plus learner ID, then split exam attempts, course progress, and recommendation events into containers with different throughput needs. Autoscale was enabled only where seasonal exam peaks justified it, while steady containers used provisioned throughput. Azure Monitor alerts flagged 429 responses and abnormal RU consumption per container. The team added tags and workbook filters for district owners, then documented query patterns so developers avoided cross-partition scans. Private endpoints and RBAC limited access to platform services. Release gates required CLI evidence for container partition keys and throughput mode before new districts were onboarded.

Potential outcomes
  • Exam progress write P95 improved from 142 milliseconds to 37 milliseconds.
  • Small-tenant support tickets during exam weeks dropped 68 percent.
  • RU cost attribution by district exposed two inefficient recommendation queries.
  • The migration completed during the semester with no application freeze.
What to learn

Azure Cosmos DB lets SaaS teams scale uneven tenant workloads when partition boundaries and cost evidence are explicit.

Azure CLI

I use Azure CLI for Azure Cosmos DB because the important facts are scattered across account, database, container, network, key, and regional settings. After a decade of Azure work, I want those facts as repeatable JSON, not screenshots from three portal blades. CLI is fast for confirming the active subscription, listing accounts, checking failover priority, exporting database and container names, reviewing private endpoint state, and capturing evidence before a capacity change. It also makes change control cleaner: the same commands can run in preflight checks, incident runbooks, and pipeline gates so operators compare live configuration against the approved design. That consistency reduces mistakes during stressful production changes.

Useful for

  • List Cosmos DB accounts across a resource group and export API type, region layout, consistency policy, and tags for architecture review.
  • Inspect a specific account before failover testing to confirm write region, automatic failover settings, backup mode, and network exposure.
  • List databases and containers so operators can map partition keys, throughput mode, and ownership before changing RU capacity.
  • Capture private endpoint and firewall evidence for compliance reviews without relying on portal screenshots.

Before you run a command

  • Confirm tenant, subscription, resource group, account name, and API type because SQL, MongoDB, Cassandra, Gremlin, Table, and vector scenarios expose different details.
  • Use read-only commands first; create, delete, failover, throughput, key, and network commands can affect availability, cost, or application access.
  • Know whether output may include keys, endpoint names, private networking details, or customer region information before saving evidence.
  • Check provider registration, RBAC permissions, and the intended output format when running inventory across multiple subscriptions.

What the output tells you

  • Account output shows regions, failover order, consistency policy, API capabilities, endpoint settings, tags, and whether the live resource matches the approved design.
  • Database and container output reveals throughput mode, partition key paths, indexing behavior, and resource IDs needed for tuning or change records.
  • Metrics and diagnostic output helps separate platform availability, 429 throttling, hot partitions, slow queries, and network access failures.

Mapped commands

Azure Cosmos DB operations

direct
az cosmosdb list --resource-group <resource-group>
az cosmosdbdiscoverDatabases
az cosmosdb show --name <account-name> --resource-group <resource-group>
az cosmosdbdiscoverDatabases
az cosmosdb create --name <account-name> --resource-group <resource-group> --locations regionName=<region>
az cosmosdbprovisionDatabases
az cosmosdb sql database list --account-name <account-name> --resource-group <resource-group>
az cosmosdb sql databasediscoverDatabases

Architecture context

In architecture reviews, Azure Cosmos DB is not just a database choice; it is a partitioning, consistency, and regional-resilience decision. I place it close to applications that need predictable low latency, high write volume, or globally distributed reads. The durable boundary is the account and its containers, but the practical behavior comes from partition keys, SDK connection mode, indexing, request-unit allocation, and region preference. It often integrates with Azure Functions, App Service, AKS, Event Hubs, Azure Monitor, Key Vault, Private Link, and analytical stores. Good designs document data ownership, failover order, access paths, backup expectations, and the exact queries the model is optimized to serve.

Security
Security for Azure Cosmos DB starts with controlling both the management plane and the data plane. Operators should restrict who can create accounts, change regions, rotate keys, adjust network access, or assign data-plane roles. Disable broad public exposure where private endpoints or firewall rules are required, store keys in Key Vault if keys are still used, and prefer Microsoft Entra authentication and RBAC where the API supports it. Encryption at rest is handled by the service, but customer-managed keys, diagnostic logs, backup access, and cross-region data residency still need review for regulated workloads. Separate production, test, and analytics consumers so one compromised identity cannot traverse every container.
Cost
Cost is driven by provisioned or autoscale request units, serverless usage, storage, analytical features, backups, and multi-region replication. The waste pattern is simple: teams overestimate peak throughput, enable extra regions, keep verbose diagnostics forever, or run cross-partition queries that burn RUs without improving outcomes. Autoscale can protect reliability but still needs a sensible maximum. FinOps reviews should connect cost to containers, partition keys, query patterns, regions, and business transactions, not just the account total. Tag ownership and alert on RU spikes before they become budget surprises. Budget alerts should be tied to business peaks, not only monthly subscription totals and owners.
Reliability
Reliability depends on whether account regions, consistency level, backup mode, client retry behavior, and partition design match the workload. Multi-region accounts can improve continuity, but failover is only useful when applications use preferred regions correctly and tolerate retries. Hot partitions, under-provisioned RUs, poor indexing, or long cross-partition queries can look like service instability even when the platform is healthy. Operators should test regional failover, monitor 429 throttling, review backup restore expectations, and document what happens when one dependency, region, or downstream consumer falls behind. Capacity alarms, synthetic transactions, and restore drills should run before business peaks, not after customers report delays or lost writes.
Performance
Performance depends on partition key design, item size, indexing policy, consistency level, SDK configuration, request-unit availability, and physical proximity to users. Point reads with the partition key are usually much cheaper and faster than broad queries. Cross-partition fan-out, hot keys, inefficient ORDER BY patterns, large documents, or chatty client code can create high latency and throttling. Operators should track P95 and P99 latency, normalized RU consumption, 429 counts, retry rates, and regional endpoint behavior. Performance tuning is mostly data-model tuning, not just adding more capacity. Load tests should include real partition distribution, item sizes, and regional client behavior under peak traffic.
Operations
Operational teams inspect Azure Cosmos DB through account settings, container properties, metrics, diagnostic logs, alerts, backup configuration, private endpoints, and SDK error patterns. Day-two work includes RU tuning, indexing reviews, key rotation, role assignment review, regional failover drills, and investigating hot partitions or expensive queries. Useful runbooks show how to find account ID, API type, regions, consistency, throughput mode, and container partition keys. Incident notes should distinguish platform availability from application query design, throttling, serialization errors, stale connection strings, and network isolation problems. Monthly reviews should also capture tenant growth, RU trends, indexing changes, client retries, and support-ready escalation contacts.

Common mistakes

  • Choosing a partition key from a familiar relational model instead of testing cardinality, access patterns, and tenant growth under realistic load.
  • Adding regions for resilience without validating SDK preferred regions, failover behavior, conflict assumptions, and data residency requirements.
  • Treating 429 responses as outages instead of capacity or hot-partition signals that should be handled with retries and design review.
  • Leaving account keys in app settings after managed identity, RBAC, Key Vault, or rotation controls were supposed to be enforced.