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
- Unlimited scalability with automatic throughput provisioning.
- Multi‑master replication across any Azure region.
- Turnkey low‑latency reads and writes with guaranteed 5‑ms reads at the 99th percentile.
- SQL queries with rich syntax for filtering, ordering, and aggregations.
- Integrated server‑less compute with Azure Functions and Azure Logic Apps.
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: