Introduction to Azure Cosmos DB

MSDN Tutorials

What is Azure Cosmos DB?

Azure Cosmos DB is a globally distributed, multi-model database service that enables you to create and interact with massively scalable, high-performance data solutions. It offers a choice of APIs, including SQL (Core API), MongoDB, Cassandra, Gremlin, and Table, providing flexibility to choose the best API for your application.

Key features of Azure Cosmos DB include:

Key Concepts

Understanding these core concepts is crucial for working with Azure Cosmos DB:

Getting Started with Cosmos DB (SQL API)

Let's walk through the basic steps to create and interact with a Cosmos DB container using the SQL API.

1. Create an Azure Cosmos DB Account

You can create an account via the Azure portal, Azure CLI, or Azure PowerShell.

Azure CLI: az cosmosdb create --name <your-cosmosdb-account-name> --resource-group <your-resource-group> --kind GlobalDocumentDB --locations regionName="West US" isZoneRedundant="false" regionName="East US" isZoneRedundant="false"

2. Create a Database and Container

Once the account is created, you can create a database and a container. We'll use a sample JSON document structure for demonstration.

Cosmos DB Portal UI Placeholder

Illustrative view of creating a container in the Azure portal.

Container Configuration:

Example JSON item:


{
    "id": "6b43035e-51b2-44e6-900a-c1a267f57739",
    "name": "Cosmos DB Tutorial Item",
    "description": "This is a sample item for the tutorial.",
    "isComplete": false,
    "category": "tutorial",
    "tags": ["cosmosdb", "azure", "tutorial"]
}
            

3. Querying Data

You can query your data using the SQL API, which uses a SQL-like syntax. Here's an example to retrieve items where the category is 'tutorial':


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

You can execute these queries directly in the Azure portal's Data Explorer, or programmatically using Azure SDKs.

What's Next?

This introduction covered the basics of Azure Cosmos DB. To dive deeper, consider exploring:

Refer to the official Azure Cosmos DB documentation for comprehensive details and advanced tutorials.

← Previous: Azure Fundamentals Next: Cosmos DB - Core API Deep Dive →