MongoDB API
Migrating from MongoDB with the Cosmos DB’s MongoDB API ensures that the transition is seamless. This compatibility allows applications already using MongoDB to migrate without substantial changes.
Here are the advantages of using the API:
■■ Smooth migration: Existing MongoDB applications can be moved with minimal modifications.
■■ Global scale: Harness Cosmos DB’s distribution and scalability features for
- your MongoDB data.
If you have a MongoDB collection for user profiles, as shown in Figure 3-13, you can use the MongoDB shell with a typical query, as shown in Figure 3-14, to fetch the user detail.

FIGURE 3-13 JSON representation of a user profile

FIGURE 3-14 Typical query done in the MongoDB shell
Cassandra API
For applications already entrenched in Apache Cassandra’s column-family data model, Cosmos DB provides the Cassandra API, ensuring that migration and integration are straightforward.
Here are the advantages of using the Cassandra API:
■■ Native support: Directly interact with column-family data models without needing to reshape your data.
■■ Enhanced performance: Leverage Azure’s robust infrastructure for better responsive-ness and uptime.
Assuming you have a table for tracking user activity, as shown in Figure 3-15, to fetch the activity for a specific user, you’d use the select statement shown in Figure 3-16.

FIGURE 3-15 Table for tracking user activity
Skill 3.2: Describe capabilities and features of Azure Cosmos DB CHAPTER 3 91
FIGURE 3-16 Fetching the activity for a specific user
Azure Table API
Aimed at applications leveraging Azure Table storage, the Azure Table API ensures that transi-tioning to Cosmos DB is smooth, offering a more potent suite of features and capabilities.
Here are the advantages of the Azure Table API:
- Seamless transition: Migrate from Azure Table storage with ease.
- Advanced features: Access Cosmos DB’s advanced toolset, from global distribution to automatic scaling.
Leave a Reply