cosmos-db
  1. cosmos-db-key-features

Key Features - Azure Cosmos DB

Azure Cosmos DB is a fully-managed, globally-distributed NoSQL database service that offers unparalleled throughput, latency, availability and consistency guarantees at a global scale. Here are some of its key features:

Syntax

Azure Cosmos DB provides several APIs to interact with the database, including SQL, MongoDB, Cassandra, Gremlin and Azure Table Storage APIs.

SELECT * FROM c WHERE c.category = "Books"

Example

const cosmos = require("@azure/cosmos");

const endpoint = "your-endpoint-url";
const key = "your-primary-key";
const client = new cosmos.CosmosClient({ endpoint, key });

// Define a database and container
const databaseId = "my-database";
const containerId = "my-container";

// Create a new database
const { database } = await client.databases.createIfNotExists({ id: databaseId });

// Create a new container
const { container } = await client.database(database.id).containers.createIfNotExists({ id: containerId });

// Insert a new document
const newItem = { id: "1", name: "John Doe", email: "johndoe@example.com" };
await container.items.create(newItem);

Output

{
    "id": "1",
    "name": "John Doe",
    "email": "johndoe@example.com"
}

Explanation

Azure Cosmos DB is designed to handle globally-distributed applications with ease, providing various APIs to interact with the database and offering robust performance and high availability. In the above example, we use the Azure Cosmos DB JavaScript SDK to create a new database and a new container before inserting a new document into it.

Use

Azure Cosmos DB is commonly used for applications that require low latency and high throughput at a global scale. It's well-suited for scenarios such as IoT data ingestion and processing, real-time gaming, and e-commerce websites that require rapid updates and high availability.

Important Points

  • Azure Cosmos DB supports multiple APIs, including SQL, MongoDB, Cassandra, Gremlin and Azure Table Storage
  • It offers automatic and manual indexing options to optimize query performance
  • It supports multiple consistency levels, providing developers with fine-grained control over read and write consistency
  • It comes with built-in global distribution and scalability options, allowing developers to easily distribute data across multiple regions and seamlessly scale up or down as needed

Summary

Azure Cosmos DB is an advanced NoSQL database service that offers exceptional performance at a global scale. With support for multiple APIs and built-in global distribution and scalability, it's well-suited for applications that require low latency and high throughput.

Published on: