Azure - CosmosDB
Execute queries and CRUD operations on Azure CosmosDB NoSQL containers.
Runs one Azure Cosmos DB (SQL API) operation on a container: a parameterized SQL query, a point read, an upsert or a delete, and returns the result under result.
Connect your Azure CosmosDB account and automate database operations — run SQL queries, read documents by ID, upsert records, and delete items.
Operations:
- Query: Execute a SQL query against a container with optional parameters.
- Read: Retrieve a single document by its ID and partition key.
- Upsert: Create or update a document in the container.
- Delete: Remove a document by its ID and partition key.
How it works
- Resolves the expressions of the node config. Empty
connection_id,database,container,operation,query,parametersandpartitionKeyfall back to the field of the same name in the incoming item;itemis taken from the config only when it has at least one key.operationdefaults toquery. - Resolves the account endpoint and key from: a raw
AccountEndpoint=…;AccountKey=…;string inconnection_id; aconnection-stringcredential with that format; or abasic-auth/objectcredential withendpointandkey(orpassword/accountKey). - Runs the operation:
queryexecutesquerywithparametersand reads every page;readanddeleteaddressitem.idwithpartitionKey(defaults toitem.id);upsertwritesitem. - Returns
{ result }onout: an array of documents forquery, the document forreadandupsert, and{ deleted: true, id }fordelete. Failures are returned as{ error }onerror.
In a workflow
The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.
{
"node_id": "node-open-orders",
"label": "Find open orders",
"operator_slug": "integrations.microsoft.azure.cosmos",
"operator_version": "1.0.0",
"config": {
"connection_id": "pi-credential-xxxx",
"database": "sales",
"container": "orders",
"operation": "query",
"query": "SELECT * FROM c WHERE c.status = @status",
"parameters": [
{
"name": "@status",
"value": "open"
}
]
}
}{
"ok": true,
"data": {
"result": [
{
"id": "ord_123",
"status": "open",
"total": 129.99,
"_rid": "q7x1AKl0VxsBAAAAAAAAAA==",
"_etag": "\"0b00a5c1-0000-0100-0000-6745f2b30000\"",
"_ts": 1764165811
}
]
},
"port": "out"
}Configuration
-
connection_idstring Required -
Credential for Azure CosmosDB (SQL API). Accepts credentials of type `connection-string` (AccountEndpoint=...;AccountKey=...;) or `basic-auth` (endpoint + key).
-
databasestring Required Accepts expressions -
Name of the CosmosDB database.
-
containerstring Required Accepts expressions -
Name of the container to operate on.
-
operationstring Optional -
The database operation to perform.
-
querystring Optional Accepts expressions -
SQL query to execute against the container (e.g., "SELECT * FROM c WHERE c.status = @status").
-
parametersarray Optional -
Array of { name, value } objects for parameterized SQL queries.
-
itemobject Optional Accepts expressions -
The document object to upsert into the container.
-
partitionKeystring Optional Accepts expressions -
Partition key value for the target document.
Behaviour in the code
What the implementation does with these keys beyond what the schema says.
-
item - Used by
readanddelete(only itsid) as well as byupsert(the whole document). An empty object is treated as missing and replaced by the incoming item'sitemfield. -
partitionKey - Ignored by
upsert(the SDK takes the partition key from the document). Forreadanddeleteit defaults toitem.id, which is only correct when the container is partitioned by/id. -
parameters - Array of
{ "name": "@status", "value": "open" }objects matching the@placeholders inquery.
Output ports
out default The operation succeeded. A query with no matches also leaves here, with result: [].
{
"result": [
{
"id": "ord_123",
"status": "open",
"total": 129.99,
"_rid": "q7x1AKl0VxsBAAAAAAAAAA==",
"_etag": "\"0b00a5c1-0000-0100-0000-6745f2b30000\"",
"_ts": 1764165811
}
]
}error Validation, credential resolution or the Cosmos call failed.
{
"error": "Query string required for query operation"
}In expressions
What a later node can read from this node's output with $("Azure - CosmosDB").item.json.<path> (write your node's label instead of Azure - CosmosDB). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through out, from the output shown in Ports.
| Expression | Editor | Worker |
|---|---|---|
$("Azure - CosmosDB").item.json.resultCosmos response Resource or FeedResponse |
Errors
| Message | Port | Cause and fix |
|---|---|---|
connection_id is required | error | No credential in the config or in the incoming item. |
Query string required for query operation | error | operation is query and query is empty. |
item.id required for <read|delete> | error | read and delete need item with an id. Set item to { "id": "…" } even though the form only shows it for upsert. |
item object required for upsert | error | upsert without a document. |
Unsupported operation: <operation> | error | operation is not query, read, upsert or delete. |
Invalid Cosmos SQL connection string format | error | The connection string lacks AccountEndpoint= or AccountKey=. |
Credential <connection_id> (type '<type>') missing endpoint / key | error | A structured credential lacks the endpoint or the key. |
Input contract
-
connection_idstring Required -
databasestring Required -
containerstring Required -
operationstring Optional -
querystring Optional -
parametersarray Optional -
itemobject Optional -
partitionKeystring Optional
Output contract
-
resultobject Optional -
Cosmos response Resource or FeedResponse
Contracts (JSON Schema)
The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.
{
"slug": "integrations.microsoft.azure.cosmos",
"name": "Azure - CosmosDB",
"category": "integrations",
"group": [
{
"key": "microsoft",
"name": "Microsoft",
"icon_url": "/icons/integrations/microsoft/microsoft.svg"
},
{
"key": "azure",
"name": "Azure",
"icon_url": "/icons/integrations/microsoft/azure.svg"
}
],
"icon_url": "/icons/integrations/microsoft/azure-cosmos.svg",
"version": "1.0.0",
"description": "Execute queries and CRUD operations on Azure CosmosDB NoSQL containers.\n\n Connect your Azure CosmosDB account and automate database operations — run SQL queries, read documents by ID, upsert records, and delete items.\n\n **Operations:**\n - **Query:** Execute a SQL query against a container with optional parameters.\n - **Read:** Retrieve a single document by its ID and partition key.\n - **Upsert:** Create or update a document in the container.\n - **Delete:** Remove a document by its ID and partition key.",
"capabilities": [
"nosql",
"database",
"cosmos",
"azure",
"cloud"
],
"config_schema": {
"type": "object",
"properties": {
"connection_id": {
"type": "string",
"title": "CosmosDB Credential",
"description": "Credential for Azure CosmosDB (SQL API). Accepts credentials of type `connection-string` (AccountEndpoint=...;AccountKey=...;) or `basic-auth` (endpoint + key).",
"ui_widget": "connection_picker",
"ui_options": {
"credential_types": [
"connection-string",
"basic-auth"
],
"types": [
"cosmos"
]
}
},
"database": {
"type": "string",
"title": "Database",
"description": "Name of the CosmosDB database.",
"format": "expression"
},
"container": {
"type": "string",
"title": "Container",
"description": "Name of the container to operate on.",
"format": "expression"
},
"operation": {
"type": "string",
"title": "Operation",
"enum": [
"query",
"read",
"upsert",
"delete"
],
"default": "query",
"description": "The database operation to perform."
},
"query": {
"type": "string",
"title": "SQL Query",
"description": "SQL query to execute against the container (e.g., \"SELECT * FROM c WHERE c.status = @status\").",
"format": "expression",
"displayOptions": {
"show": {
"operation": [
"query"
]
}
}
},
"parameters": {
"type": "array",
"title": "Query Parameters",
"description": "Array of { name, value } objects for parameterized SQL queries.",
"displayOptions": {
"show": {
"operation": [
"query"
]
}
}
},
"item": {
"type": "object",
"title": "Document",
"description": "The document object to upsert into the container.",
"format": "expression",
"displayOptions": {
"show": {
"operation": [
"upsert"
]
}
}
},
"partitionKey": {
"type": "string",
"title": "Partition Key",
"description": "Partition key value for the target document.",
"format": "expression",
"displayOptions": {
"show": {
"operation": [
"read",
"upsert",
"delete"
]
}
}
}
},
"required": [
"connection_id",
"database",
"container"
]
},
"input_contract_schema": {
"type": "object",
"properties": {
"connection_id": {
"type": "string"
},
"database": {
"type": "string"
},
"container": {
"type": "string"
},
"operation": {
"type": "string"
},
"query": {
"type": "string"
},
"parameters": {
"type": "array"
},
"item": {
"type": "object"
},
"partitionKey": {
"type": "string"
}
},
"required": [
"connection_id",
"database",
"container"
]
},
"output_contract_schema": {
"type": "object",
"properties": {
"result": {
"type": "object",
"description": "Cosmos response Resource or FeedResponse"
}
}
},
"ports": [
{
"port_id": "out",
"label": "Result",
"description": "Operation result or items",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Error occurred during execution",
"is_default": false,
"supports_condition": false
}
],
"execution_mode": "async",
"required_resources": [],
"compatible_worker_pools": [
"standard-io",
"cloud-io"
],
"tags": [
"nosql",
"azure"
],
"is_stateful": false,
"publisher": {
"identity": "org_sommatic_ai",
"profile": {
"name": "Sommatic AI",
"verified": true,
"url": "https://sommatic.ai",
"logo_url": null
}
}
}{
"type": "object",
"properties": {
"connection_id": {
"type": "string",
"title": "CosmosDB Credential",
"description": "Credential for Azure CosmosDB (SQL API). Accepts credentials of type `connection-string` (AccountEndpoint=...;AccountKey=...;) or `basic-auth` (endpoint + key).",
"ui_widget": "connection_picker",
"ui_options": {
"credential_types": [
"connection-string",
"basic-auth"
],
"types": [
"cosmos"
]
}
},
"database": {
"type": "string",
"title": "Database",
"description": "Name of the CosmosDB database.",
"format": "expression"
},
"container": {
"type": "string",
"title": "Container",
"description": "Name of the container to operate on.",
"format": "expression"
},
"operation": {
"type": "string",
"title": "Operation",
"enum": [
"query",
"read",
"upsert",
"delete"
],
"default": "query",
"description": "The database operation to perform."
},
"query": {
"type": "string",
"title": "SQL Query",
"description": "SQL query to execute against the container (e.g., \"SELECT * FROM c WHERE c.status = @status\").",
"format": "expression",
"displayOptions": {
"show": {
"operation": [
"query"
]
}
}
},
"parameters": {
"type": "array",
"title": "Query Parameters",
"description": "Array of { name, value } objects for parameterized SQL queries.",
"displayOptions": {
"show": {
"operation": [
"query"
]
}
}
},
"item": {
"type": "object",
"title": "Document",
"description": "The document object to upsert into the container.",
"format": "expression",
"displayOptions": {
"show": {
"operation": [
"upsert"
]
}
}
},
"partitionKey": {
"type": "string",
"title": "Partition Key",
"description": "Partition key value for the target document.",
"format": "expression",
"displayOptions": {
"show": {
"operation": [
"read",
"upsert",
"delete"
]
}
}
}
},
"required": [
"connection_id",
"database",
"container"
]
}{
"type": "object",
"properties": {
"connection_id": {
"type": "string"
},
"database": {
"type": "string"
},
"container": {
"type": "string"
},
"operation": {
"type": "string"
},
"query": {
"type": "string"
},
"parameters": {
"type": "array"
},
"item": {
"type": "object"
},
"partitionKey": {
"type": "string"
}
},
"required": [
"connection_id",
"database",
"container"
]
}{
"type": "object",
"properties": {
"result": {
"type": "object",
"description": "Cosmos response Resource or FeedResponse"
}
}
}[
{
"port_id": "out",
"label": "Result",
"description": "Operation result or items",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Error occurred during execution",
"is_default": false,
"supports_condition": false
}
]Execution
- Execution
async- Stateful
- No
- Credentials
- Resolved on the server from
connection_id; the secret never reaches the workflow. - Capabilities
nosqldatabasecosmosazurecloud- Tags
nosqlazure
Notes and limits
queryloads every page into memory. AddTOPorOFFSET … LIMITto bound large containers.- A
readof a missing document does not fail: the SDK returns no resource, so the node leaves throughoutwithout aresultvalue. - There is no
emptyport and the worker adds no retries of its own.
Reviewed against the orchestrator code · 31e874b · 2026-11-26