StudyToCert

All certifications / AI-200 / Lessons

Microsoft Certified: Azure AI Cloud Developer Associate AI-200 (replaced AZ-204) · Domain 2: Develop AI solutions by using Azure data management services

Cosmos DB for NoSQL with the Python SDK (azure-cosmos): CosmosClient, create/upsert/read/delete items, parameterized queries

▶ Watch the overview video

Last reviewed October 6, 2026 · Leer en español

Explain it simpler

Cosmos DB is a database that stores small JSON documents, a bit like a huge filing cabinet of index cards. Each card has a name (its id) and a drawer label (its partition key). The Python library, called azure-cosmos, gives you one main object, CosmosClient, that opens the cabinet. You make it once and keep using it. Then you can add a card (create), add or overwrite a card (upsert), fetch one card when you know its name and drawer (read), or throw a card away (delete). When you search, you hand the search words over separately instead of gluing them into the question, the same way a librarian writes your request on a form instead of letting you scribble on the catalog itself.

It is Monday morning at Lakeside Outfitters, a fictional online gear shop, and Priya on the platform team is staring at a dashboard full of red. The order service is logging dozens of 409 Conflict errors, and a few customers have emails saying their order failed even though the warehouse already packed it. Overnight, the queue redelivered a batch of messages, and every repeat insert blew up. Meanwhile, a security reviewer has flagged a query built with an f-string from a search box. Two small coding choices are causing both problems. Which SDK methods and query style would have kept this service calm?

Azure Cosmos DB for NoSQL is a globally distributed database that stores JSON documents called items. The resource model is a simple hierarchy: items live in containers, containers live in databases, and databases live in an account. Every item has an id and a value for the container's partition key, and together those two values uniquely identify the item. The same id can appear in two different partitions, which surprises people the first time they see it. In Python, you work with all of this through the azure-cosmos package, alongside azure-identity for authentication.

Free account

Keep reading for free

Create a free StudyToCert account to read the rest of this lesson: 8 more sections, 6 key terms, a real-world example, an exam tip and self-check questions. Every lesson, lab and practice test is free with an account.

Sign up free Log in

Study AI-200 for free
A week-by-week plan with every lesson, quizzes, checkpoint tests, a practice exam and hands-on labs.
Open the AI-200 study plan