Azure Cosmos DB

Azure Cosmos DB is a globally distributed, multi-model database service. It provides a highly available, low-latency, and elastic data store that supports multiple data models, including document, key-value, graph, and column-family.

Key Features and Benefits

  • Global Distribution: Distribute data across any number of Azure regions for high availability and disaster recovery.
  • Multiple APIs: Supports SQL (Core) API, MongoDB API, Cassandra API, Gremlin API, and Table API.
  • Guaranteed Throughput and Latency: Offers predictable performance with financially backed SLAs.
  • Schema-Agnostic: Designed to work with data of any structure, making it ideal for modern applications.
  • Elastic Scalability: Scale throughput and storage independently and on demand.
  • Tunable Consistency: Choose from five well-defined consistency levels to balance performance and data freshness.

Common Use Cases

  • IoT Data Ingestion and Processing
  • Gaming Leaderboards and Player Data
  • Web and Mobile Applications
  • E-commerce Platforms
  • Real-time Analytics

Getting Started

Begin your journey with Azure Cosmos DB by creating an account and exploring its capabilities. Here are some helpful resources:

Core Concepts

Accounts

An Azure Cosmos DB account is the top-level resource. It contains databases, containers, and items.

Databases

A database is a logical namespace that holds a set of containers.

Containers

A container is the entity that holds data. It can be a collection of documents, a graph, or a table.

Items

Items are the fundamental units of data that are stored in a container. They can be JSON documents, rows, or nodes/edges in a graph.

Partition Keys

Partition keys are crucial for distributing data across logical partitions within a container, enabling scalability and high performance.

Example: Creating a Document with the SQL API

Here's a simple example of how you might create a JSON document using the SQL (Core) API.

// Example using Azure Cosmos DB SDK for .NET
var cosmosClient = new CosmosClient("YOUR_COSMOS_DB_CONNECTION_STRING");
var database = cosmosClient.GetDatabase("MyDatabase");
var container = database.GetContainer("MyContainer");

var newItem = new {
    id = "unique-item-id",
    name = "Sample Item",
    description = "This is a sample item for demonstration.",
    category = "Demo",
    tags = new[] { "example", "document" }
};

await container.CreateItemAsync(newItem, new PartitionKey("Demo"));
console.log("Item created successfully!");
                
Learn More about Azure Cosmos DB