DP-900: Microsoft Azure Data Fundamentals
Cosmos DB
Application Programming Interfaces APIs
Now that we’ve covered why Azure Cosmos DB is an outstanding semi-structured data platform and how to provision a Cosmos DB account, this article dives into the five supported APIs. You’ll learn how and when to use the native NoSQL (Core) API, MongoDB, Cassandra, Gremlin (graph), and Table Storage. By the end, you’ll be able to pick the right interface for your workload.
Two core advantages differentiate Cosmos DB from Azure Storage Accounts:
- Global distribution & geo-redundancy
Deploy multiple writable regions worldwide for low-latency reads and writes with built-in replication. - Infinite throughput scalability
Purchase as many Request Units (RUs) per second as you need—up to tens of millions—without the fixed limits of Azure Storage.
NoSQL (Core) API
The native NoSQL API stores JSON documents and offers a familiar SQL-like query language for JSON data. If you’re coming from relational databases, you can leverage your SQL skills to query documents.
Key features:
- JSON-document model with automatic indexing
- SQL-style queries:
SELECT * FROM c WHERE c.category = 'electronics'
- Cross-partition queries with rich filtering and aggregation
Note
The Core API automatically indexes all JSON properties by default, so there’s no need to manage schema migrations.
MongoDB API
Azure Cosmos DB’s MongoDB API is wire-protocol compatible with existing MongoDB drivers. Simply point your application at Cosmos DB—no code changes required. You can also enforce schemas using JSON Schema validation.
Key points:
- Full support for MongoDB wire protocol v3.2+
- Zero-downtime migration with the Azure Cosmos DB Data Migration tool
- Optional JSON Schema enforcement for stricter models
Note
You can leverage MongoDB tools like mongoexport
or mongodump
to migrate data directly into Cosmos DB.
Cassandra API
Built for wide-column workloads, the Cassandra API lets you define column families to group related columns for fast reads and writes. It’s wire-compatible with existing Cassandra drivers.
Highlights:
- Uses Cassandra Query Language (CQL) for familiar syntax
- Support for existing Cassandra driver versions
- Integrate with Apache Spark or Azure Databricks for ETL and analytics
Gremlin (Graph) API
The Gremlin API enables graph databases where both vertices (nodes) and edges (relationships) can store properties. It excels when you need to traverse complex relationships.
Common scenarios:
- Social networks (friends, followers)
- Network topology mapping (devices, connections)
- Fraud detection with path-finding queries
Table Storage API
If you need a simple key-value store with schema-less tables, the Table Storage API gives you the same programming model as Azure Storage Tables—plus Cosmos DB’s global distribution and unlimited RUs.
Key advantages:
- PartitionKey/RowKey indexing for fast lookups
- Automatic horizontal partitioning and replication
- Ideal for telemetry, session stores, and lightweight metadata
API Comparison
API | Data Model | Query Language | Best Use Case |
---|---|---|---|
Core (NoSQL) | JSON documents | SQL-like | Flexible JSON workloads with rich querying |
MongoDB | JSON documents | MongoDB Query API | Existing MongoDB apps with minimal changes |
Cassandra | Wide-column | CQL | High-throughput columnar reads/writes |
Gremlin (Graph) | Graph | Gremlin traversal | Complex relationship queries and traversals |
Table Storage | Key-value | OData / Table query | Simple schema-less tables with fast lookups |
Links and References
- Azure Cosmos DB documentation
- MongoDB Compatibility
- Cassandra API in Azure Cosmos DB
- Gremlin API in Azure Cosmos DB
- Azure Storage Tables vs Cosmos DB Tables
Watch Video
Watch video content