Roadmap › Microsoft Azure for .NET Developers › Module: Data and Storage
Lessons in this course (14)

7. Azure SQL and Cosmos DB

Intermediate★ Must knowLesson 7 of 14

Azure SQL family: Azure SQL Database (single DB or elastic pool; vCore or DTU; serverless auto-pause; Hyperscale up to 128 TB), Azure SQL Managed Instance (near-100% SQL Server compatibility — SQL Agent, cross-DB queries; lift-and-shift), SQL Server on Azure VMs (full control). Built-in HA, automated backups with point-in-time restore, geo-replication/failover groups, Entra authentication, Defender for SQL, read replicas.

Azure Cosmos DB: globally distributed, multi-model NoSQL with single-digit-millisecond latency SLA.

  • APIs: NoSQL (native), MongoDB (RU and vCore), Apache Cassandra, Gremlin (graph), Table, plus PostgreSQL (distributed, Citus).
  • Partition key choice is critical: high cardinality, evenly distributed, used in most queries (avoid hot partitions; cross-partition queries cost more).
  • Request Units (RU/s) — throughput currency: provisioned (manual/autoscale) or serverless.
  • Consistency levels (strongest → weakest): Strong, Bounded Staleness, Session (default), Consistent Prefix, Eventual.
  • Change feed for event-driven processing; TTL; multi-region writes.
csharp
var client = new CosmosClient("https://cosmos-shop.documents.azure.com:443/", new DefaultAzureCredential());
var container = client.GetContainer("shop", "orders");             // partition key: /customerId
await container.UpsertItemAsync(order, new PartitionKey(order.CustomerId));
var item = await container.ReadItemAsync<Order>(order.id, new PartitionKey(order.CustomerId));   // point read: ~1 RU