Azure Cosmos DB SDK for Python
Build Cosmos DB applications with Python SDK
Working with globally distributed databases requires understanding partition keys and efficient queries. This skill provides production-ready patterns for Azure Cosmos DB operations using the official Python SDK.
Descargar el ZIP de la skill
Subir en Claude
Ve a Configuración → Capacidades → Skills → Subir skill
Activa y empieza a usar
Pruébalo
Usando "Azure Cosmos DB SDK for Python". Query items where price is less than 500 in the electronics partition
Resultado esperado:
Returns a list of product documents matching the price filter, sorted by partition key for efficient single-partition retrieval with minimal request unit consumption.
Usando "Azure Cosmos DB SDK for Python". Upsert a new product item with id, category, name, and price fields
Resultado esperado:
Creates the item if it does not exist or replaces it if it exists, returning the created or updated document with system-generated metadata like _ts and _rid.
Auditoría de seguridad
SeguroThis is a prompt-only skill containing documentation and code examples for Azure Cosmos DB SDK. Static analysis found 0 security issues with a risk score of 0/100. The skill provides legitimate database operation patterns using official Azure SDK libraries. Network and environment access patterns shown are standard Azure authentication flows requiring user-provided credentials.
Factores de riesgo
🌐 Acceso a red
🔑 Variables de entorno
Puntuación de calidad
Lo que puedes crear
E-commerce Product Catalog
Build a globally distributed product catalog with partition key optimization for fast lookups by category and efficient range queries for price filtering.
IoT Telemetry Storage
Store and query time-series sensor data using hierarchical partition keys for tenant and device isolation with automatic global replication.
User Session Management
Implement low-latency session storage with automatic failover across Azure regions using Cosmos DB consistency levels and TTL policies.
Prueba estos prompts
Create a Python script that connects to Azure Cosmos DB and performs create, read, update, and delete operations on a container storing user profiles with partition key /user_id.
Write a query function that retrieves products under a maximum price within a specific category partition using parameterized SQL to prevent injection and improve caching.
Implement an async Python function that batches and inserts 1000 items into Cosmos DB using the async client with proper error handling and retry logic for rate limiting.
Generate a setup script that creates a Cosmos DB container with hierarchical partition keys, provisioned throughput of 5000 RU/s, and appropriate indexing policies for a multi-tenant event logging system.
Mejores prácticas
- Always specify partition key for point reads and queries to minimize latency and cost
- Use parameterized queries instead of string concatenation to prevent injection attacks
- Design partition keys for even data distribution to avoid hot partitions
Evitar
- Performing cross-partition queries without enable_cross_partition_query flag
- Using read_all_items without partition key filtering in production workloads
- Creating containers without planning partition key strategy upfront