Dev & Engineering ✓ Microsoft · Official azure-cosmos-dbpython-sdknosqldocument-crudpartition-keyparameterized-query

Azure Cosmos DB for Python

A practical guide for building reliable Python applications on Azure Cosmos DB’s NoSQL API.

FollowSkills review · FSRS-2.0
Use with care
54/ 100 5-point scale 2.7 / 5
1 2 3 4 5 6
1Trust18 / 25 · 3.6/5

The skill recommends DefaultAzureCredential, discourages keys, uses parameterized queries, and emphasizes deterministic client cleanup, providing partial least-privilege and data-flow safety guidance. However, create, replace, delete, and throughput-changing operations lack user confirmation, rollback, or recovery guidance; sensitive-data handling, dependency security, and complete source attribution are also missing, so points are deducted.

2Reliability8 / 20 · 2.0/5

It covers sync/async lifecycle management, common HTTP statuses, and retry feedback, making the happy path plausible. However, the core setup omits the PartitionKey import, several advanced examples have insufficient concurrency/API-compatibility/edge-case treatment, and no skill-specific execution evidence is supplied; the static cap keeps this at 8.

3Adaptability9 / 15 · 3.0/5

Triggers and scenarios for Python SDK CRUD, queries, and partition keys are reasonably clear, and cross-partition queries are identified as a costly non-preferred case. Input prerequisites, non-fit boundaries, compatibility ranges, and conditional fallback guidance remain incomplete; the documentation is English-only and gives no Chinese-language or mainland-China reachability guidance, so points are deducted.

4Convention9 / 15 · 3.0/5

The document has installation, environment variables, authentication, workflows, references, and a script entry, plus MIT licensing, author metadata, and version 1.0.0. It lacks a skill-specific changelog, explicit maintenance/update path, FAQ, and systematic troubleshooting; the referenced files and script are not included in the supplied evidence, preventing a full score.

5Effectiveness6 / 15 · 2.0/5

The material covers CRUD, queries, pagination, aggregations, transactions, change feed, and partition design, offering useful direct guidance for common Cosmos DB coding tasks. However, the examples are not a complete runnable implementation and require checking imports, permissions, service prerequisites, and potentially unsafe advanced patterns; static evidence supports only 6.

6Verifiability4 / 10 · 2.0/5

The skill, repository README, license, security policy, and CI files are auditable primary repository materials, and the repository reports evaluation and testing workflows. There are no path-specific committed tests, real execution results, or independent corroboration in the supplied files, so this remains 4.

Evidence confidence:Low Reviewed Jul 20, 2026 Reviewed revision 9ccaf7c3704a
Before you use it
  • Before executing writes, deletes, throughput changes, or transaction examples, confirm the target account, database, container, permissions, and recovery plan with the user.
  • The core database/container example omits the PartitionKey import; do not assume every advanced example is compatible with the installed azure-cosmos version.
  • Add SDK version constraints, skill-specific tests, troubleshooting, sensitive-data guidance, and Chinese/mainland-China reachability notes.
See the full review method →

What does this skill do, and when should you use it?

This skill targets the Azure Cosmos DB NoSQL API and covers client lifecycle, databases, containers, document CRUD, queries, partition keys, and throughput. It includes both synchronous and asynchronous Python examples and recommends DefaultAzureCredential for authentication. The guidance emphasizes context managers for clients and async credentials, plus explicit partition-key usage for efficient operations. It is a good fit for developers integrating Cosmos DB into Python services or scripts.

Provides the installation command for azure-cosmos and azure-identity; documents COSMOS_ENDPOINT, COSMOS_DATABASE, COSMOS_CONTAINER, and production AZURE_TOKEN_CREDENTIALS settings; explains CosmosClient, DatabaseProxy, and ContainerProxy; demonstrates database and container creation, item creation, point reads, replacement, upserts, deletion, parameterized queries, cross-partition queries, projections, throughput reads and updates; and includes synchronous, asynchronous, and CosmosHttpResponseError handling examples.

  1. A Python developer needs to create or retrieve a Cosmos DB database and a partitioned container.
  2. A backend engineer needs document create, point-read, replace, upsert, and delete operations.
  3. A service developer needs parameterized queries within a partition or an explicitly controlled cross-partition query.
  4. A high-throughput Python application needs the asynchronous Cosmos client and async DefaultAzureCredential.
  5. An application or operations developer needs to inspect or change provisioned container throughput.

What are this skill's strengths and limitations?

Pros
  • Covers both synchronous and asynchronous clients with practical common-operation examples.
  • Clearly promotes DefaultAzureCredential, context managers, and parameterized queries.
  • Addresses partition keys, cross-partition queries, throughput, and 404/429 handling.
  • Points to reference material for partitioning and query patterns, plus a container setup script.
Limitations
  • Focused on Python and the Azure Cosmos DB NoSQL API rather than other languages or API models.
  • It identifies cross-partition queries as more expensive but provides no concrete cost or performance benchmarks.
  • The source does not provide skill-specific test results or test scenarios.
  • The async pattern requires azure.identity.aio and separate context managers for the async client and credential.

How do you install this skill?

Run pip install azure-cosmos azure-identity. To install the broader Agent Skills collection, run npx skills add microsoft/skills and select the required skill in the wizard; the collection is installed into the selected agent directory, such as .github/skills/. The source does not document a dedicated command for installing only azure-cosmos-py.

How do you use this skill?

In an Agent Skills-compatible coding agent, ask: “Use azure-cosmos and azure-identity to implement document CRUD and parameterized queries for a Cosmos DB NoSQL container with a partition key.” Before running the generated code, configure COSMOS_ENDPOINT, COSMOS_DATABASE, and COSMOS_CONTAINER; for production DefaultAzureCredential usage, also set AZURE_TOKEN_CREDENTIALS=prod or a specific credential name.

How does this skill compare with similar options?

Compared with connection strings, account keys, or API keys, the skill favors DefaultAzureCredential so the same code can work across local development and Azure environments while preserving Entra auditing and credential rotation practices.

FAQ

Which environment variables are required?
COSMOS_ENDPOINT, COSMOS_DATABASE, and COSMOS_CONTAINER are required for all authentication methods. AZURE_TOKEN_CREDENTIALS is required only when DefaultAzureCredential is used in production.
Do operations always need a partition key?
Point reads and efficient queries should specify one. The skill recommends always specifying partition keys for point operations and queries and warns that cross-partition queries are more expensive.
Does the skill support asynchronous Cosmos DB code?
Yes. It includes azure.cosmos.aio.CosmosClient, azure.identity.aio.DefaultAzureCredential, asynchronous CRUD operations, and asynchronous query iteration.
How should missing items and throttling be handled?
The example catches CosmosHttpResponseError, checks for 404 and 429, reads x-ms-retry-after-ms for throttling, and re-raises other status codes.

More skills from this repository

All from microsoft/agent-skills

Dev & Engineering ✓ Microsoft · Official

Azure Cosmos DB for Rust

A practical guide to building Rust applications with the official Azure Cosmos DB NoSQL client.

Dev & Engineering ✓ Microsoft · Official

Azure Cosmos DB TypeScript Skill

Gives TypeScript and JavaScript coding agents practical Cosmos DB data-access patterns.

Dev & Engineering ✓ Microsoft · Official

Azure Cosmos DB Python Service Builder

Build secure, testable Azure Cosmos DB NoSQL services for Python and FastAPI applications.

Dev & Engineering ✓ Microsoft · Official

Azure Cosmos DB Java Skill

Guides Java developers in building globally distributed, partitioned, and reactive Azure Cosmos DB applications.

Dev & Engineering ✓ Microsoft · Official

Azure Tables Java Skill

Build Java applications for Azure Table Storage and the Cosmos DB Table API.

Dev & Engineering ✓ Microsoft · Official

Azure Tables for Python

A practical guide to building authenticated Azure Tables applications with Python entity CRUD, queries, and partition-scoped batch operations.

Dev & Engineering ✓ Microsoft · Official

Azure Key Vault SDK for Python

Gives Python coding agents practical guidance for securely managing Azure Key Vault secrets, keys, and certificates.

Dev & Engineering ✓ Microsoft · Official

Azure Monitor Query for Python

Generate Python code for querying Azure Monitor logs and metrics.

Dev & Engineering ✓ Microsoft · Official

Azure Document Translation for Python

Batch-translate Azure Blob Storage documents in Python while preserving their original formats.

Dev & Engineering ✓ Microsoft · Official

Azure AI Search for Python

Helps Python developers build vector, hybrid, and semantic search applications with Azure AI Search.

Dev & Engineering ✓ Microsoft · Official

Azure Identity for Python

A practical skill for securing Python Azure applications with Microsoft Entra ID credentials.

Dev & Engineering ✓ Microsoft · Official

Azure AI Vision Image Analysis

Guides Python coding agents in implementing Azure AI Vision image understanding.

Dev & Engineering ✓ Microsoft · Official

Azure Blob Storage for Python

Guides secure, production-minded Blob Storage operations in Python.

Dev & Engineering ✓ Microsoft · Official

Azure Queue Storage for Python

Gives coding agents reliable Python patterns for secure Azure Queue Storage messaging and asynchronous task processing.

Dev & Engineering ✓ Microsoft · Official

Azure API Management for Python

Gives coding agents practical Python SDK patterns for managing Azure API Management services, APIs, products, subscriptions, and policies.

Dev & Engineering ✓ Microsoft · Official

Azure Cosmos DB ARM for .NET

Provision and manage Azure Cosmos DB resources from .NET through ARM.

Dev & Engineering ✓ Microsoft · Official

Azure AI Content Safety for Python

Guides Python applications in detecting harmful text and images and enforcing custom blocklists.

Dev & Engineering ✓ Microsoft · Official

Azure App Configuration for Python

Centralize Python application settings, feature flags, and dynamic configuration in Azure.

Dev & Engineering ✓ Microsoft · Official

Azure Container Registry for Python

Manage Azure container images, artifacts, and repositories from Python.

Dev & Engineering ✓ Microsoft · Official

Azure Monitor Custom Log Ingestion

Guides Python agents to send custom logs to Log Analytics through the Logs Ingestion API.

Related skills