On this page
Sommatic Docs
Open portal

Azure - CosmosDB

Execute queries and CRUD operations on Azure CosmosDB NoSQL containers.

View as Markdown
Open in
Integrations Available integrations.microsoft.azure.cosmos Version 1.0.0 Execution: async

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

  1. Resolves the expressions of the node config. Empty connection_id, database, container, operation, query, parameters and partitionKey fall back to the field of the same name in the incoming item; item is taken from the config only when it has at least one key. operation defaults to query.
  2. Resolves the account endpoint and key from: a raw AccountEndpoint=…;AccountKey=…; string in connection_id; a connection-string credential with that format; or a basic-auth / object credential with endpoint and key (or password / accountKey).
  3. Runs the operation: query executes query with parameters and reads every page; read and delete address item.id with partitionKey (defaults to item.id); upsert writes item.
  4. Returns { result } on out: an array of documents for query, the document for read and upsert, and { deleted: true, id } for delete. Failures are returned as { error } on error.

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"
      }
    ]
  }
}

Configuration

connection_id string Required

Credential for Azure CosmosDB (SQL API). Accepts credentials of type `connection-string` (AccountEndpoint=...;AccountKey=...;) or `basic-auth` (endpoint + key).

database string Required Accepts expressions

Name of the CosmosDB database.

container string Required Accepts expressions

Name of the container to operate on.

operation string Optional

The database operation to perform.

Default: query

Allowed values: queryreadupsertdelete

query string Optional Accepts expressions

SQL query to execute against the container (e.g., "SELECT * FROM c WHERE c.status = @status").

Shown when: operation = query

parameters array Optional

Array of { name, value } objects for parameterized SQL queries.

Shown when: operation = query

item object Optional Accepts expressions

The document object to upsert into the container.

Shown when: operation = upsert

partitionKey string Optional Accepts expressions

Partition key value for the target document.

Shown when: operation = read | upsert | delete

Behaviour in the code

What the implementation does with these keys beyond what the schema says.

item
Used by read and delete (only its id) as well as by upsert (the whole document). An empty object is treated as missing and replaced by the incoming item's item field.
partitionKey
Ignored by upsert (the SDK takes the partition key from the document). For read and delete it defaults to item.id, which is only correct when the container is partitioned by /id.
parameters
Array of { "name": "@status", "value": "open" } objects matching the @ placeholders in query.

Output ports

out default

The operation succeeded. A query with no matches also leaves here, with result: [].

Data
{
  "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.

Data
{
  "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.

ExpressionEditorWorker
$("Azure - CosmosDB").item.json.resultobject= […] (1)Cosmos 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_id string Required
database string Required
container string Required
operation string Optional
query string Optional
parameters array Optional
item object Optional
partitionKey string Optional

Output contract

result object 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
    }
  }
}

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

  • query loads every page into memory. Add TOP or OFFSET … LIMIT to bound large containers.
  • A read of a missing document does not fail: the SDK returns no resource, so the node leaves through out without a result value.
  • There is no empty port and the worker adds no retries of its own.

Reviewed against the orchestrator code · 31e874b · 2026-11-26

Install agent tools

Give your coding agent the official Sommatic AI docs: skills, the docs MCP server and Markdown pages, so it never has to scrape the site.

Skills only. They do not update by themselves; run it again to refresh.

npx skills add https://docs.sommatic.ai
How agents read these docs