Technical & DevelopmentIntermediate
azure-cosmos-db-py
Cosmos DB with Python/FastAPI patterns
Developer Setup
Setup & Installation
bash
npx skills add https://github.com/microsoft/skills --skill azure-cosmos-db-pynpx skills add https://github.com/microsoft/skills --skill azure-cosmos-db-pyOr paste this URL into your assistant to install:
Overview
What This Skill Does
Guides Python and FastAPI code toward production-ready Azure Cosmos DB NoSQL integrations. Covers client setup with dual authentication (DefaultAzureCredential for Azure, key-based for the local emulator), service layer patterns with CRUD operations, partition key strategies, and parameterized queries. Includes TDD fixtures for mocking the Cosmos container in pytest.
Application
When to use this Skill
- Configuring integration settings for custom agent workflows.
- Optimizing query execution and response latency in production.
- Developing clean, standard-compliant implementations for enterprise services.
- Troubleshooting connection timeouts and authentication handshakes.
- Monitoring API rate limits and execution pipelines programmatically.
Documentation
Show Skills.md file
Cosmos DB Service Implementation
Build production-grade Azure Cosmos DB NoSQL services following clean code, security best practices, and TDD principles.
Installation
pip install azure-cosmos azure-identity
Environment Variables
COSMOS_ENDPOINT=https://<account>.documents.azure.com:443/ # Required for all auth methods
COSMOS_DATABASE_NAME=<database-name> # Required for all auth methods
COSMOS_CONTAINER_ID=<container-id> # Required for all auth methods
# For emulator only (not production)
COSMOS_KEY=<emulator-key> # Only required for key-based auth or emulator
AZURE_TOKEN_CREDENTIALS=prod # Required only if DefaultAzureCredential is used in production
Authentication & Lifecycle
🔑 Two rules apply to every code sample below:
Lines 1 - 25 of 262
Recommendations