Azure Cosmos DB SQL API – Introduction

The Azure Cosmos DB SQL API provides a JSON document model with a SQL‑like query language, enabling developers to build highly responsive and globally distributed applications.

Key Features

Getting Started

Below is a minimal example that creates a database, a container, and inserts a document using the .NET SDK.

using Microsoft.Azure.Cosmos;

var client = new CosmosClient("", "");
var database = await client.CreateDatabaseIfNotExistsAsync("SampleDB");
var container = await database.Database.CreateContainerIfNotExistsAsync(
    new ContainerProperties("Items", "/partitionKey"));

var item = new { id = "item1", name = "Cosmos Item", partitionKey = "pk1" };
await container.Container.CreateItemAsync(item, new PartitionKey(item.partitionKey));

Run Queries

Use the SQL API to query documents with familiar syntax.

SELECT c.id, c.name
FROM c
WHERE c.partitionKey = @pk
ORDER BY c.name ASC

Resources

Explore more topics: