Azure Cosmos DB

Azure Cosmos DB is a globally distributed, multi-model database service. It provides a rich set of features designed for modern application development, including guaranteed low latency, high availability, and elastic scalability.

Key Features:

  • Globally Distributed: Replicate your data across any number of Azure regions.
  • Multi-Model: Supports document, key-value, graph, and column-family data models.
  • Guaranteed Throughput & Latency: Offers predictable performance with Service Level Agreements (SLAs).
  • Elastic Scalability: Scale throughput and storage independently and on demand.
  • Multiple APIs: Works with familiar APIs like SQL (Core), MongoDB, Cassandra, Gremlin, and Table.

Getting Started with Azure Cosmos DB

This section guides you through the initial steps of creating and configuring an Azure Cosmos DB account.

1. Create a Cosmos DB Account

You can create an Azure Cosmos DB account using the Azure portal, Azure CLI, or Azure PowerShell.

Using the Azure Portal:
  1. Navigate to the Azure portal.
  2. Click "Create a resource".
  3. Search for "Azure Cosmos DB" and select it.
  4. Click "Create".
  5. Configure the necessary settings, including the API, subscription, resource group, region, and capacity mode.
  6. Click "Review + create" and then "Create".

Tip: For development and testing, you can use the free tier or a local emulator to experiment without incurring costs.

2. Choose an API

Azure Cosmos DB supports multiple APIs, allowing you to use the database with your existing knowledge and tools:

3. Connect to Your Cosmos DB Account

Once your account is created, you'll need to obtain connection strings and keys to interact with your data. These can be found in the "Keys" section of your Cosmos DB resource in the Azure portal.


# Example using Azure CLI to get connection string
az cosmosdb keys list --name mycosmosdbaccount --resource-group myresourcegroup --type connection-strings
            

Common Use Cases

Azure Cosmos DB is ideal for a wide range of applications:

Data Modeling and Partitioning

Effective data modeling and partitioning are crucial for performance in Azure Cosmos DB. Choose a logical partition key that distributes requests evenly across physical partitions.

Important: A well-chosen partition key is essential for scaling and performance. Avoid hot partitions by ensuring your partition key has high cardinality and distributes data evenly.

Learn More