January 28th, 2026
0 reactions

Accelerate Your Cosmos DB Infrastructure with GitHub Copilot CLI and Azure Cosmos DB Agent Kit

Sajeetharan Sinnathurai
Principal Program Manager

Modern infrastructure work is increasingly agent driven, but only if your AI actually understands the platform you’re deploying. This guide shows how to turn GitHub Copilot CLI into an Azure Cosmos DB aware infrastructure expert by loading the Azure Cosmos DB Agent Kit. In under a minute, you’ll give Copilot deep, opinionated knowledge of Azure Cosmos DB best practices so it can review, generate, and optimize your Terraform, Bicep, Docker, and CI/CD configurations directly from your terminal.

TL;DR — Get Started in 30 Seconds

npx add-skill AzureCosmosDB/cosmosdb-agent-kit
copilot
> Review my Terraform config for Azure Cosmos DB multi-region best practices:
> @infra/main.tf

That’s it! Copilot CLI now has expert-level Azure Cosmos DB infrastructure knowledge for your IaC workflows.


What is GitHub Copilot CLI?

GitHub Copilot CLI is a terminal-native AI coding agent that brings the full power of GitHub Copilot to your command line. Unlike browser-based tools, it works directly in your development environment with full context awareness.

Key Capabilities

Feature What it does for Infrastructure Engineers
Agentic coding Generate, review, and refactor Terraform, Bicep, and Docker configs
File system access Read and modify IaC modules, Dockerfiles, and CI/CD pipelines
Terminal execution Run terraform plan, docker build, az cli commands directly
Git integration Commit infrastructure changes, manage feature branches
MCP support Connect to Azure Resource Graph, state backends, and registries
Agent Skills Load domain-specific knowledge (Azure Cosmos DB best practices)

Installation

Windows:

winget install GitHub.Copilot

macOS/Linux:

brew install copilot-cli
# or
curl -fsSL https://gh.io/copilot-install | bash

Launch with:

copilot

Quick Setup

Prerequisites

  1. GitHub Copilot CLI installed and authenticated
  2. Active Copilot subscription (Pro, Pro+, Business, or Enterprise)
  3. Version 0.0.390+ — Run copilot --version to check

Install the Skill

Option 1: One command (recommended)

npx add-skill AzureCosmosDB/cosmosdb-agent-kit

Option 2: Manual install

git clone https://github.com/AzureCosmosDB/cosmosdb-agent-kit.git
mkdir -p ~/.copilot/skills
cp -r cosmosdb-agent-kit/skills/cosmosdb-best-practices ~/.copilot/skills/

Option 3: Project-level (team sharing)

mkdir -p .github/skills
cp -r cosmosdb-agent-kit/skills/cosmosdb-best-practices .github/skills/
git add .github/skills && git commit -m "Add Cosmos DB skill"

Verify Installation

copilot
> What's wrong with enabling multiple_write_locations without proper conflict resolution?

Skill loaded: Mentions conflict resolution policies, Last Writer Wins, custom stored procedures ❌ Skill not loaded: Generic advice about multi-region databases

Example: Review Terraform Configuration

Use Copilot CLI to review your Azure Cosmos DB Terraform modules for infrastructure anti-patterns.

Prompt:

@infra/cosmosdb/main.tf

Review this Terraform config for Cosmos DB best practices:
- Multi-region setup
- Consistency policy
- Throughput configuration
- Backup settings

Copilot CLI reads the file directly and applies the skill’s 45+ rules to identify issues like:

  • Missing zone redundancy for 99.995% SLA
  • Incorrect consistency level for the use case
  • Fixed throughput instead of autoscale
  • Missing automatic failover configuration
  • Suboptimal partition key strategy

Example: Generate Terraform Module

Generate production-ready Azure Cosmos DB Terraform configuration.

Prompt:

Generate a Terraform module for Cosmos DB with:
- Multi-region deployment (East US primary, West US secondary)
- Zone redundancy enabled
- Autoscale throughput 400-4000 RU/s
- Hierarchical partition key support
- Continuous backup with 7-day retention

What Copilot generates:

Configuration Best Practice Applied
automatic_failover_enabled = true High availability
zone_redundant = true 99.995% SLA
partition_key_version = 2 Hierarchical partition keys
backup.type = "Continuous" Point-in-time restore

Save directly to your infra directory:

> Write that to infra/modules/cosmosdb/main.tf

Example: Docker Compose with Azure Cosmos DB Emulator

Generate local development infrastructure using the Cosmos DB emulator.

Prompt:

Generate a docker-compose.yml for local development with:
- Cosmos DB emulator container
- My .NET API container that connects to it
- Proper networking and health checks
- Environment variables for connection strings

Copilot generates the complete Docker Compose configuration:

> Save that to docker-compose.dev.yml

Example: Review Indexing Policy for IaC

Optimize the indexing policy defined in your Terraform or Bicep configuration.

Prompt:

@infra/cosmosdb/main.tf

My container queries by tenantId, status, and orders by createdAt.
Review and optimize the indexing_policy block for these query patterns.

What Copilot suggests:

Optimization Impact
Add composite index (tenantId, createdAt DESC) Efficient ORDER BY
Exclude /payload/* from indexing Reduce storage costs
Use included_path instead of wildcard Lower RU for writes
Add spatial index if using geo queries Enable geo-filtering

Example: CI/CD Pipeline Integration

Generate GitHub Actions workflow for Cosmos DB infrastructure deployment.

Prompt:

Generate a GitHub Actions workflow that:
- Runs terraform plan on PRs
- Runs terraform apply on merge to main
- Uses OIDC authentication to Azure
- Has separate jobs for dev/staging/prod environments

Copilot generates the workflow and can write it directly:

> Write that to .github/workflows/infra-deploy.yml

Example: Bicep Module Review

Review Azure Bicep configurations for Azure Cosmos DB best practices.

Prompt:

@infra/cosmosdb.bicep

Review this Bicep module for:
- Proper use of parameters vs variables
- Security best practices (private endpoints, managed identity)
- Cost optimization settings

Tips for Effective Prompts

Technique Example
Reference IaC files with @ @infra/main.tf Review this for multi-region best practices
Be specific about concerns “Review for HA and DR settings” vs “Review this config”
Chain actions “Generate the module, then write it to infra/modules/cosmosdb/”
Ask for explanations Add “…and explain the tradeoffs” for architecture decisions
Include constraints “…with budget under $500/month” or “…for dev environment”

Troubleshooting

Problem Solution
Skill not loading Update CLI: winget upgrade GitHub.Copilot
Generic responses Verify skill exists: ls ~/.copilot/skills/cosmosdb-best-practices/
Still not working Try project-level install in .github/skills/
Need latest rules Re-run: npx add-skill AzureCosmosDB/cosmosdb-agent-kit

Resources

Leave a Review

Tell us about your Azure Cosmos DB experience! Leave a review on PeerSpot and get a $50 gift. Get started here.

About Azure Cosmos DB

Azure Cosmos DB is a fully managed and serverless NoSQL and vector database for modern app development, including AI applications. With its SLA-backed speed and availability as well as instant dynamic scalability, it is ideal for real-time NoSQL and MongoDB applications that require high performance and distributed computing over massive volumes of NoSQL and vector data.

To stay in the loop on Azure Cosmos DB updates, follow us on XYouTube, and LinkedIn.

Author

Sajeetharan Sinnathurai
Principal Program Manager

Principal Product Manager passionate about empowering developers with exceptional tools and experiences. Currently part of the Azure Cosmos DB team, driving developer-focused features like JavaScript SDK, integrations, and tooling for local development etc. Interested in web development or cloud? Let’s connect!

0 comments