Thanks to visit codestin.com
Credit goes to officialskills.sh

Back to skills

azure-cosmos-db-py

officialdata

Guides Python and FastAPI code toward production-ready Azure Cosmos DB NoSQL integrations.

Setup & Installation

npx skills add https://github.com/microsoft/skills --skill azure-cosmos-db-py
or paste the link and ask your coding assistant to install it
https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-python/skills/azure-cosmos-db-py
View on GitHub

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.

It encodes the non-obvious production details — RBAC auth, parameterized queries, partition key isolation, async wrapping, and graceful degradation — that are easy to get wrong when wiring Cosmos DB into FastAPI for the first time.

When to use it

  • Setting up a Cosmos DB singleton client that switches between Azure RBAC and the local emulator automatically
  • Writing a service class with get, create, update, and delete methods backed by Cosmos DB documents
  • Designing partition key schemes to avoid cross-partition scans on a multi-tenant dataset
  • Adding pytest fixtures that mock the Cosmos container without a live database connection
  • Mapping Pydantic models to Cosmos documents with camelCase JSON aliases and a five-tier model hierarchy