Azure Cosmos DB Documentation

Azure Cosmos DB is a globally distributed, multi-model database service that enables you to harness the benefits of global distribution and horizontal scalability with low latency.

Key Features:
  • Globally distributed
  • Multi-model support (Document, Key-Value, Graph, Column-Family)
  • Guaranteed low latency and high throughput
  • Elastic scalability
  • Multiple consistency levels

Getting Started with Cosmos DB

This section provides an introduction to Azure Cosmos DB, including its core concepts, benefits, and how to get started with creating your first database account.

Core Concepts

  • Accounts: A Cosmos DB account is the top-level resource.
  • Databases: A database is a logical container for collections.
  • Collections (Containers): A collection is a set of documents. In API for NoSQL, these are called Containers.
  • Documents: JSON documents (or other data structures depending on the API).
  • Partition Keys: Used for horizontal scaling and distributing data.
  • Request Units (RUs): A normalized measure of throughput.

Create a Cosmos DB Account

You can create an Azure Cosmos DB account through the Azure portal, Azure CLI, or Azure SDKs.

  1. Navigate to the Azure portal.
  2. Click "Create a resource".
  3. Search for "Azure Cosmos DB" and select it.
  4. Click "Create".
  5. Fill in the required details, such as subscription, resource group, account name, API, and location.

Tutorials

Explore these tutorials to learn how to perform common tasks:

Key APIs and Data Models

Azure Cosmos DB supports multiple data models and APIs, allowing you to choose the best fit for your application.

API for NoSQL (formerly DocumentDB)

This is the native API for Cosmos DB, offering document storage with SQL-like query capabilities. It uses containers and documents.


{
    "id": "myDocumentId",
    "category": "books",
    "name": "Azure Cosmos DB Essentials",
    "author": "Jane Doe",
    "tags": ["database", "azure", "nosql"]
}
                

Azure Cosmos DB for MongoDB

Provides compatibility with MongoDB, allowing you to use existing MongoDB applications and drivers with Cosmos DB.

Azure Cosmos DB for Apache Cassandra

Offers compatibility with Apache Cassandra, enabling you to leverage your existing Cassandra knowledge and tools.

Azure Cosmos DB for PostgreSQL

A fully managed PostgreSQL service with distributed capabilities, offering horizontal scaling and high availability.

Azure Cosmos DB for Gremlin

Supports the Gremlin graph traversal language, ideal for applications that work with complex relationships and graph data.

Performance and Scalability

Understand how to optimize performance and scale your Cosmos DB solution effectively.

Throughput Provisioning

Throughput is provisioned in Request Units (RUs) per second. You can provision throughput at the container or database level.

Autoscale: Automatically scales throughput based on demand.

Manual: You set a fixed RU/s value.

Partitioning Strategies

Choosing the right partition key is crucial for efficient data distribution and query performance. A good partition key distributes requests evenly across logical partitions.

Tip: Select a partition key with high cardinality and even data distribution.

Security and Access Control

Learn how to secure your data in Azure Cosmos DB.

  • Role-Based Access Control (RBAC): Manage permissions for users and applications.
  • Primary Keys and Resource Tokens: For direct access to data.
  • Firewall: Restrict network access to your Cosmos DB account.
  • Private Endpoints: Securely connect to your Cosmos DB account.

Pricing

Azure Cosmos DB pricing is based on throughput (RUs) and storage consumed. Different APIs may have slightly different pricing models.

Visit the Azure Cosmos DB Pricing page for detailed information.

Last Updated: October 26, 2023 Version: 1.2.0 Feedback