Lesson content
Read, practise, then check your understanding
Databases: Azure SQL and Cosmos DB
Azure SQL Database offers a managed SQL Server-compatible relational platform with backups, scaling, availability, and security features. Azure Cosmos DB provides globally distributed NoSQL APIs with tunable consistency and throughput measured through request units.
Core ideas
- An Azure SQL logical server is an administrative and connection boundary, not a customer-managed database host.
- Service tiers and compute models balance latency, scaling, availability, and cost.
- Cosmos DB partitions data by a partition key; a poor key can create hot partitions.
- Cosmos DB consistency choices trade freshness guarantees, availability behavior, and latency.
Design and operating model
Start with relationships, transaction boundaries, query patterns, latency, geography, expected scale, and recovery objectives. Use Azure SQL for relational integrity and SQL workloads. Use Cosmos DB when its data model, APIs, global distribution, and scale characteristics fit. Test with representative data and queries.
Example
az sql db create \
--resource-group learning-rg \
--server replace-with-sql-server \
--name learningdb \
--edition GeneralPurpose \
--family Gen5 \
--capacity 2
az cosmosdb show \
--resource-group learning-rg \
--name replace-with-cosmos-account
Run examples in a disposable training subscription. Replace names, Regions, identifiers, scopes, sizes, and policies with reviewed values, and confirm current Azure CLI and service requirements before production use.
Production guidance
- Use Microsoft Entra authentication, private networking, auditing, encryption, and least privilege.
- Enable and rehearse point-in-time recovery or geo-restore based on business objectives.
- For Cosmos DB, estimate request units from real operations and monitor throttling and partition distribution.
The chapter quiz follows the lesson and checks both service vocabulary and architecture decisions.
Knowledge check
Answer every question correctly to complete this chapter.
0 of 10 checks passed
Your progress is saved on this device.