Skills Azure Cosmos DB SDK for Java
📦

Azure Cosmos DB SDK for Java

Safe 🔑 Env variables

Build Cosmos DB Applications with Java

Integrating Azure Cosmos DB into Java applications requires understanding SDK patterns and best practices. This skill provides comprehensive guidance for database operations, reactive programming, and global distribution.

Supports: Claude Codex Code(CC)
📊 69 Adequate
1

Download the skill ZIP

2

Upload in Claude

Go to Settings → Capabilities → Skills → Upload skill

3

Toggle on and start using

Test it

Using "Azure Cosmos DB SDK for Java". Create a CosmosClient with session consistency and preferred regions

Expected outcome:

CosmosClient configured with endpoint from environment variables, session consistency level, preferred regions (West US, East US), direct mode connection, and user agent suffix for application identification.

Using "Azure Cosmos DB SDK for Java". Query users where status equals active

Expected outcome:

Parameterized SQL query executed against Cosmos container, returning CosmosPagedIterable of User objects filtered by status parameter, with results iterated and printed to console.

Security Audit

Safe
v1 • 2/24/2026

This is a prompt-only skill containing documentation and code examples for Azure Cosmos DB Java SDK. Static analysis scanned 0 files with 0 findings and a risk score of 0/100. The skill provides instructional content for database operations without any executable code. The only risk factor is env_access for environment variable usage in authentication examples, which is standard practice for credential management.

0
Files scanned
0
Lines analyzed
1
findings
1
Total audits

Risk Factors

🔑 Env variables (1)
Audited by: claude

Quality Score

38
Architecture
100
Maintainability
87
Content
31
Community
100
Security
74
Spec Compliance

What You Can Build

Enterprise Application Developer

Build scalable backend services that store and retrieve data from globally distributed Cosmos DB containers with proper partitioning strategies.

Cloud Migration Specialist

Migrate existing database applications to Azure Cosmos DB with guidance on SDK integration and consistency model selection.

Full-Stack Developer

Implement reactive data access patterns using the async client for high-throughput scenarios in modern web applications.

Try These Prompts

Basic Client Setup
Show me how to create a CosmosClient in Java using environment variables for the endpoint and key. Include proper error handling.
Container Creation with Partition Key
Generate Java code to create a database and container in Cosmos DB. The container should use /userId as the partition key. Use the async client pattern.
CRUD Operations with Reactive Pattern
Write Java code that creates, reads, updates, and deletes a user document in Cosmos DB using reactive chains with the async client. Include proper error handling for each operation.
Optimized Query with Request Options
Create a parameterized SQL query in Java that retrieves users by status from Cosmos DB. Configure CosmosQueryRequestOptions for optimal performance and iterate through paged results.

Best Practices

  • Reuse CosmosClient instance throughout your application - creating new clients is expensive
  • Choose partition keys with high cardinality and even distribution for optimal scaling
  • Use async client for high-throughput scenarios and reactive programming patterns

Avoid

  • Creating new CosmosClient instances for each operation - causes connection pool exhaustion
  • Using strong consistency level without understanding latency implications across regions
  • Ignoring 429 rate limit responses - always implement retry logic or use built-in retry policy

Frequently Asked Questions

What is the difference between CosmosClient and CosmosAsyncClient?
CosmosClient is synchronous and blocks until operations complete. CosmosAsyncClient uses reactive programming with non-blocking operations, better for high-throughput scenarios.
How do I handle authentication for Cosmos DB in Java?
Use key-based authentication with endpoint and key from environment variables. Store credentials securely and never hardcode them in source code.
What consistency level should I choose for my application?
Session consistency is recommended for most applications. Strong consistency has higher latency. Eventual consistency offers lowest latency but no ordering guarantees.
How do I optimize query performance in Cosmos DB?
Use parameterized queries, select only needed properties, leverage partition key in WHERE clauses, and configure appropriate request options for your query patterns.
What happens when I exceed my provisioned RU/s?
Cosmos DB returns 429 status code with retry-after header. The SDK has built-in retry logic, but you should also handle this in your application code.
Can I use this skill for other Cosmos DB APIs besides NoSQL?
This skill focuses on the NoSQL (SQL) API. MongoDB, Cassandra, Gremlin, and Table APIs have different SDKs and connection patterns.

Developer Details

File structure

📄 SKILL.md