Microsoft is letting AI agents query your Azure Cosmos DB data

Microsoft wants AI agents to do more than generate code and answer questions. The company is bringing agentic AI deeper into Azure Cosmos DB, giving developers new ways to let AI tools understand database structure, generate queries, and even execute them.

For anyone who doesn’t spend the day thinking about databases, Azure Cosmos DB is Microsoft’s cloud database service for storing and retrieving large amounts of information used by apps and websites. Think of a shopping app storing products and customer orders, for example. Instead of a developer manually figuring out how to ask the database for certain information, an AI agent could potentially understand how that data is organized and help retrieve what is needed.

One of the more interesting additions involves GitHub Copilot inside Visual Studio Code. When working with Azure Cosmos DB, Copilot can use the developer’s active database context, inspect container schemas, generate queries based on that information, and place those queries directly into the Cosmos DB Query Editor. With developer approval, those queries can then be executed against the database.

That last part is important because Microsoft isn’t simply having Copilot spit out a query and leaving everything else to the developer. The AI can participate directly in the database workflow, potentially eliminating several manual steps.

Microsoft says Copilot can sample documents from a container to understand its schema before generating a query. In simpler terms, it can look at examples of how the information is organized before deciding how to search it. That should reduce the likelihood of the AI inventing fields or making assumptions about how the data is structured.

There is a cost consideration here too, as sampling data consumes Azure Cosmos DB request units. Those request units are essentially how Microsoft measures the computing resources consumed by database operations, so letting an AI agent poke around isn’t necessarily free. Microsoft therefore requires developers to approve the operation first, while query execution similarly requires explicit consent.

Microsoft is also introducing Azure Cosmos DB agent skills designed to give AI coding assistants more specialized knowledge about the database. Its Cosmos DB Agent Kit contains more than 100 recommendations covering areas such as data modeling, partition key selection, indexing, query optimization, throughput, vector search, and other Cosmos DB development practices.

Interestingly, Microsoft isn’t restricting those skills to GitHub Copilot. According to the company, the Agent Kit can work with GitHub Copilot, Claude Code, Codex, Cursor, Gemini CLI, and other compatible AI agents. That could make the tooling considerably more useful to developers who have already settled on an assistant outside Microsoft’s ecosystem.

There is an MCP angle here as well. MCP, or Model Context Protocol, is a standard that lets AI systems connect to external tools and data sources. Cosmos DB Shell can optionally function as an MCP server, exposing database operations as tools that compatible AI clients can use. Microsoft says this runs locally rather than operating as a Microsoft-hosted managed MCP service.

Taken together, these capabilities move AI coding assistants further away from being glorified autocomplete tools. An agent that understands the database it is working with, knows Microsoft’s Cosmos DB recommendations, generates queries using the real schema, and can execute those queries is potentially much more useful.

Of course, it is potentially more dangerous too. Giving an AI agent access to a database raises obvious questions about accidental queries, unexpected resource consumption, permissions, and sensitive information.

Microsoft appears well aware of those concerns. The company says existing Azure Cosmos DB authentication and authorization controls still apply, while potentially consequential operations such as sampling data and executing queries require developer approval.

There is a big difference between an AI assistant suggesting a database query and an AI agent actually interacting with your data. Microsoft clearly wants agents doing more of the latter, and whether developers are comfortable with that is another question.

Support independent tech journalism

NERDS.xyz is independently owned and operated. If you enjoy my coverage of Linux, AI, hardware, cybersecurity, and tech culture, consider supporting the site on Ko-fi.

Support NERDS.xyz
Written by

Brian Fagioli

Technology journalist and founder of NERDS.xyz

Brian Fagioli is a technology journalist and founder of NERDS.xyz. A former BetaNews writer, he has spent over a decade covering Linux, hardware, software, cybersecurity, and AI with a no nonsense approach for real nerds.

Leave a Comment