Cloud service · Azure · Updated

Azure Cosmos DB - Azure Cosmos DB is a fully managed, globally distributed NoSQL and vector database service for applications that require scalable throughput and low-latency data access.

In short

Azure Cosmos DB stores operational data and distributes it across Azure regions, with configurable consistency, managed replication, and consumption-based throughput options. Its API for NoSQL supports JSON documents, SQL-like queries, and vector search, while compatibility APIs support additional application models and protocols.

Cloud Services Hub →

9 key features of Azure Cosmos DB

01
Global distribution and regional failover

Replicate data across selected Azure regions to place reads closer to applications and support regional recovery. Configure write regions, failover behavior, and SDK regional preferences together, and test the resulting availability and consistency behavior.

02
Partitioned storage and elastic throughput

Azure Cosmos DB manages physical partitions as data and throughput requirements grow. Engineers control logical partitioning and must select keys that avoid hot partitions and excessive cross-partition queries.

03
Configurable consistency

Choose among strong, bounded staleness, session, consistent prefix, and eventual consistency where supported. Session consistency is useful for applications that need read-your-writes behavior without imposing strong consistency on all clients.

04
JSON queries and indexing

The API for NoSQL supports SQL-like queries over JSON documents and indexes document properties automatically by default. Tune indexing policies and add appropriate composite indexes to support production queries while controlling write costs.

05
Vector and hybrid retrieval

Store embeddings alongside operational documents and use vector search for similarity-based retrieval. Combine vector and text retrieval where supported, and use semantic reranking to improve the ordering of candidate results.

06
Change feed processing

Process document changes to build materialized views, synchronize downstream systems, or drive event-based workflows. Select the feed mode deliberately and make consumers idempotent because processing can be retried.

07
Workload throughput controls

Use throughput buckets to limit the maximum throughput consumed by individual workloads sharing a container. For example, constrain an ETL job so it does not consume the entire throughput allocation needed by interactive requests.

08
Backup and recovery

Use native continuous backup for point-in-time operational recovery. Azure Backup adds isolated, immutable vaulted backups with long-term retention of up to 10 years for compliance and recovery requirements.

09
Application identity and network protection

For supported APIs, use Microsoft Entra identities and data-plane role assignments instead of distributing account keys. Combine authorization with private endpoints, firewall rules, encryption, and diagnostic logging according to the deployment's security requirements.

Where Azure Cosmos DB is used

  1. 01
    Global web and mobile applications

    Store user profiles, preferences, sessions, and application state with regional reads close to users. Select consistency and failover settings based on whether the application prioritizes immediate visibility of updates, availability, or geographic latency.

  2. 02
    Multitenant software platforms

    Store tenant-scoped documents using partition keys aligned with tenant access patterns. Use hierarchical partitioning where appropriate, monitor large tenants separately, and apply workload controls to reduce contention between background processing and interactive traffic.

  3. 03
    Product catalogs and shopping carts

    Represent products with varying attributes as JSON documents and maintain low-latency shopping-cart state. Keep updates that require atomicity within the same logical partition, and use change feed processing to update search indexes or downstream projections.

  4. 04
    IoT operational state and telemetry

    Maintain device state and recent telemetry for applications that need frequent writes and targeted device lookups. Use time-to-live policies for short-lived data where supported, and send historical data to an analytical or archival store rather than retaining everything in the operational database.

  5. 05
    Retrieval-augmented generation and recommendations

    Store source documents, metadata, and embeddings together so retrieval can use both semantic similarity and application filters. Refresh embeddings when source content changes and evaluate retrieval quality against representative application questions.

  6. 06
    Event-driven materialized views

    Use the change feed to maintain read-optimized summaries, synchronize external indexes, or propagate business-state changes. Design consumers for replay and duplicate delivery, and explicitly handle deletion requirements.

How Azure Cosmos DB is priced

Manual provisioned throughput

Reserve a configured amount of throughput in RU/s at the container or shared-database level where supported, with charges based on provisioned capacity over time. This suits predictable workloads; replicated regions, storage, and applicable data transfer add to the total cost.

Autoscale provisioned throughput

Set a maximum throughput and let the service adjust capacity within the supported autoscale range. Billing reflects autoscale rules and the highest capacity reached during the billing hour at the applicable partition and region granularity, rather than simply the average number of requests.

Serverless consumption

Pay for request units consumed by database operations and for stored data without reserving RU/s. This is useful for intermittent or variable workloads, but serverless has different capacity and regional capabilities from provisioned-throughput accounts.

Reserved capacity

Purchase eligible provisioned-throughput capacity commitments for a one-year or three-year term to reduce throughput costs. Size reservations against sustained usage and verify which account configurations and meters qualify; storage and unrelated charges are not covered automatically.

Storage, replication, and optional capabilities

Data and index storage are billed separately from throughput, and regional replication increases the resources being billed. Backup retention, restore operations, analytical capabilities, data transfer, and Azure Backup can introduce additional charges depending on configuration.

Free tier

Eligible accounts can receive 1,000 RU/s of provisioned throughput and 25 GB of storage free under the Azure Cosmos DB free-tier rules. Enable free tier when creating the account; it is limited to one qualifying account per subscription and does not apply to serverless accounts.

Services Azure Cosmos DB works with

A common application architecture places an API in Azure App Service and uses Azure Cosmos DB for operational JSON data. The application uses a supported SDK, managed identity where available, and private networking when required. Regional application deployments should align SDK region preferences with the database's replication topology.

For ingestion, Azure Event Hubs provides a buffer between producers and database writers. Consumers validate events, choose partition keys, and write at a rate that respects available throughput. After data is committed, Azure Functions can process the change feed to update derived views or downstream systems. Use idempotent processing and explicit deletion handling rather than assuming exactly-once delivery or a complete event history.

Azure AI Search can maintain a separate retrieval index when applications need search-specific ranking and indexing capabilities. Azure Monitor provides metrics, logs, and alerts for throttling, latency, and capacity planning. Azure Backup complements native recovery with isolated long-term protection. Treat search freshness, ingestion lag, backup retention, and restore testing as explicit operational requirements.

Azure Functions

Use the Azure Cosmos DB trigger for Azure Functions to process supported change feed events without running a dedicated polling service. For example, update an order summary whenever an order document changes. Configure the lease container and throughput, and make handlers idempotent because changes can be delivered more than once.

Event Hubs

Use Event Hubs to buffer incoming telemetry or application events before a consumer writes them to Azure Cosmos DB. For example, a Functions or stream-processing consumer can validate device events and update each device's current-state document. Coordinate consumer concurrency with available RU/s, and use stable identifiers or conditional updates to handle replay safely.

App Service

Host an application API in App Service and access Azure Cosmos DB through a supported SDK. For example, a catalog API can use managed identity and NoSQL data-plane roles to read product documents without storing account keys. Reuse SDK clients and configure App Service networking and private DNS when accessing a private endpoint.

Azure Monitor

Send Azure Cosmos DB metrics and diagnostic logs to Azure Monitor for operational visibility. For example, alert on sustained throttling and correlate normalized RU consumption, request latency, and application failures to identify hot partitions or insufficient capacity. Enable only the required diagnostic categories and manage log retention to control monitoring costs.

Azure Backup

Use Azure Backup to protect supported Azure Cosmos DB accounts with vaulted backups isolated from the production account. For example, retain immutable recovery copies for regulatory requirements that exceed native continuous-backup retention. Configure retention, authorization safeguards, and recovery procedures, then test restores independently of regional failover.

API Management

Azure Cosmos DB for NoSQL can serve as a direct REST backend for API Management. An API gateway can authenticate to Cosmos DB with a managed identity and expose selected item operations without a separate application backend.

Azure Advisor

Azure Cosmos DB accounts receive resource-specific recommendations in Azure Advisor. For example, Advisor can identify eligible workloads that could save money by switching from standard provisioned throughput to autoscale.

Azure AI Bot Service

Azure Cosmos DB for NoSQL provides persistent bot state through the Bot Framework's Cosmos DB partitioned storage provider. A bot can resume a conversation after a restart or continue it on another instance.

Azure Analysis Services

Azure Cosmos DB for NoSQL data can be imported into an Azure Analysis Services tabular model through the Azure Cosmos DB Power Query connector. For example, product documents can become a table in a semantic model used for reporting.

Azure App Testing

Azure Cosmos DB can be added as an application component in Azure Load Testing, part of Azure App Testing. During a test, database metrics such as request counts and request-unit consumption can be compared with application latency and errors.

Alternatives to Azure Cosmos DB in other clouds

AWS

Amazon DocumentDB (with MongoDB compatibility)Amazon DocumentDB (with MongoDB compatibility)

Amazon DocumentDB and Azure Cosmos DB are managed document databases that support MongoDB workloads through DocumentDB’s MongoDB-compatible API and Azure Cosmos DB’s API for MongoDB, respectively. DocumentDB bills provisioned instances by runtime, while Cosmos DB bills provisioned throughput based on capacity measured in request units per second (RU/s).

Compare fact by fact
Azure Cosmos DBAmazon DocumentDB (with MongoDB compatibility)
Provisioned capacity billingProvisioned throughput (RU/s)Instance runtime
Discount commitment terms1 or 3 years1 year
Free usageFree tier for eligible accounts30-day trial for new customers
Amazon DynamoDBAmazon DynamoDB

Amazon DynamoDB and Azure Cosmos DB are fully managed NoSQL databases that scale throughput and replicate data across regions. DynamoDB supports atomic transactions across tables and bills on-demand reads and writes per request, while Azure Cosmos DB for NoSQL limits transactional batches to one logical partition and Cosmos DB serverless bills by request units consumed.

Compare fact by fact
Azure Cosmos DBAmazon DynamoDB
Transaction scopeOne logical partition (API for NoSQL)Across one or more tables
Consumption billingPer request unit (RU) consumedPer read or write request
Query modelSQL-like queries over JSONPartition and sort key queries
Amazon Keyspaces (for Apache Cassandra)Amazon Keyspaces (for Apache Cassandra)

Amazon Keyspaces and Azure Cosmos DB are managed NoSQL databases that support Cassandra workloads and multi-region replication. Keyspaces focuses on Cassandra compatibility and meters on-demand reads and writes separately, while Cosmos DB offers Cassandra as one of several APIs and uses a common request unit for database operations.

Compare fact by fact
Azure Cosmos DBAmazon Keyspaces (for Apache Cassandra)
Database APIsCassandra, NoSQL, and other APIsCassandra-compatible API
On-demand request meteringRequest units across operationsSeparate read and write request units
Discount commitments1- or 3-year throughput reservation1-year hourly spend commitment

What is Azure Cosmos DB

2 min read

Azure Cosmos DB is designed for operational applications that need predictable data access as traffic, data volume, and geographic reach grow. Microsoft manages the underlying infrastructure, patching, replication, and physical partition management. Engineers remain responsible for choosing partition keys, modeling documents around access patterns, configuring indexes, and selecting throughput and reliability settings.

For new document-oriented applications, Azure Cosmos DB for NoSQL provides JSON storage, SQL-like queries, and native SDKs. Compatibility APIs include MongoDB, Apache Cassandra, Gremlin, and Table; protocol compatibility does not imply complete behavioral equivalence with the original database. Features, limits, authentication options, and integration support vary by API, so validate the selected API against application requirements before migration.

Partition-key design is a primary architectural decision. Choose keys that distribute storage and request traffic while allowing frequent queries to target a limited set of partitions. A tenant identifier can provide useful query locality, but a very large or unusually active tenant can create an uneven workload. Hierarchical partition keys can support more granular distribution for appropriate NoSQL workloads. Point reads using both the item identifier and partition key are generally more efficient than queries that search for the same item.

Database operations consume request units, or RUs, which represent their resource cost. Provisioned throughput reserves RU/s, autoscale adjusts provisioned throughput within configured bounds, and serverless charges for consumed request units. Measure representative reads, writes, and queries rather than sizing from document count alone. Large documents, extensive indexing, and cross-partition queries can increase consumption. Monitor throttling and SDK diagnostics, and use bounded retries that respect server retry guidance.

Configure regional replication and failover according to latency, availability, and recovery requirements. Multi-region writes are available for supported configurations, but require deliberate conflict-resolution design. The five consistency levels are strong, bounded staleness, session, consistent prefix, and eventual. Their availability and behavior depend on the account configuration and API; stronger consistency can increase latency or read cost. Use SDK regional preferences and test application behavior during regional failures.

For NoSQL applications, transactions through transactional batches are scoped to a single logical partition. Model related updates accordingly rather than assuming relational joins or unrestricted distributed transactions. Automatic indexing simplifies initial development, but production indexing policies should match actual query patterns. Vector indexes allow embeddings to be stored and searched alongside operational documents for retrieval and recommendation scenarios.

Use change feed processing to maintain derived views, update search indexes, or trigger downstream workflows. Consumers should tolerate retries and duplicate processing. Latest-version change feed is not a complete audit history and does not capture deletes; select a suitable feed mode or explicitly model deletion events when downstream systems must observe them.

Secure access with supported identity-based authorization, least-privilege permissions, and appropriate network controls. Enable diagnostic telemetry and configure backups before production deployment. Native continuous backup supports point-in-time recovery, while Azure Backup adds isolated, immutable long-term protection. Replication protects availability but does not replace backups against accidental deletion or application-level corruption.

Azure architecture icons are the property of Microsoft. BlowStack is not affiliated with or endorsed by Microsoft.

AWS architecture icons are the property of Amazon Web Services. BlowStack is not affiliated with or endorsed by AWS.