Azure Cosmos DB
DatabaseConnect AI agents to Azure Cosmos DB through the Core (SQL) API. Agents manage databases and containers and create, read, query, replace, upsert, and delete documents.
What This Integration Enables
Agents persist and retrieve application state, events, or records in a globally distributed store, provision databases and containers as part of environment setup, run parameterized SQL queries with cross-partition execution enabled, upsert or replace documents to keep a container in sync with an external source, and page through documents with continuation tokens. Query Documents runs parameterized SQL with cross-partition execution, so filtering on the partition key is not required, though gateway-served queries do not support ORDER BY, aggregates, or GROUP BY.
Without FlowRunner
With FlowRunner
Use Case Scenarios
Keeping a container in sync
An upstream connector produces records. The agent calls Upsert Document for each, keyed by its partition key value, so the container stays in sync with the source: existing documents are replaced, and new ones are created. Re-running the flow never duplicates a record.
Tenant provisioning
When onboarding a new tenant, the agent calls Create Database and Create Container to provision storage with a defined partition key path, then logs the created resource ids for tracking, mirroring them into [Azure Table Storage](/integrations/azure-table-storage) as a cheaper structured record. Provisioning becomes a repeatable flow step.
Teardown with a human gate
At the end of a tenant's lifecycle, an agent is asked to remove its container or database. Before it runs Delete Container or Delete Database, it does not act on its own. It routes the resource id and a summary for approval, and deletes it only after a person confirms.
Human-in-Loop Highlight
Deleting a container or a database in Cosmos DB removes every document inside it, and there is no undo from the flow. FlowRunner's answer is human-in-the-loop, an execution pattern where the agent pauses on its own, assembles the context and the choices, routes to a human on their preferred channel, and resumes the moment they respond. When a flow reaches Delete Container or Delete Database, the agent pauses before executing and asks through Slack: "Ready to Delete Container `orders` in database `tenant-42`. This removes all of its documents. Approve or cancel?" The delete runs only after a person confirms, with the approver and timestamp captured in the run log. A connector can drop any container; an orchestration layer knows which drops should stop and ask.
Agent Capabilities
15 actionsDatabases
4- Create Database Creates a Cosmos DB database, for provisioning storage as part of environment setup.
- Delete Database Permanently deletes a database and everything in it.
- Get Database Returns the metadata of one database.
- List Databases Lists the databases in the account, for discovery.
Containers
4- Create Container Creates a container with a defined hash partition key path.
- Delete Container Permanently deletes a container and all of its documents.
- Get Container Returns the metadata of one container, including its partition key definition.
- List Containers Lists the containers in a database, for discovery.
Documents
7- Create Document Creates a document in a container. The document's partition key value is required.
- Delete Document Deletes a document by id and partition key value.
- Get Document Fetches a document by id and partition key value.
- List Documents Pages through a container's documents using continuation tokens.
- Query Documents Runs a parameterized SQL query with cross-partition execution, so filtering on the partition key is not required.
- Replace Document Replaces a document by id and partition key value with a new body.
- Upsert Document Inserts a document, or replaces it if one with the same id already exists, to keep a container in sync with an external source.
Start building with Azure Cosmos DB
$100 in credits. No card required. Connect in minutes.