Azure Cosmos DB icon

Azure Cosmos DB

Connects to Azure Cosmos DB and sends data

Overview

This node connects to Azure Cosmos DB and inserts a new item (document) into a specified database container. It is useful for automating the process of adding data to Cosmos DB from n8n workflows, such as logging events, storing processed results, or integrating with other systems that require persistent storage in Cosmos DB.

Practical examples:

  • Storing user form submissions directly into Cosmos DB.
  • Logging IoT device data into a Cosmos DB container.
  • Saving processed API responses for later analysis.

Properties

Name Meaning
Database ID The ID of the database to connect to in Azure Cosmos DB.
Container ID The ID of the container to connect to in Azure Cosmos DB.
Partition Key The partition key to use in Azure Cosmos DB.
Connection String The connection string used to authenticate and connect to Azure Cosmos DB.
Item The JSON object representing the item/document to be inserted into the Cosmos DB container.

Output

The output is an array of JSON objects, each representing the resource (item/document) created in Azure Cosmos DB. The structure of each output object matches the structure of the input "Item" property, along with additional metadata fields added by Cosmos DB (such as id, _rid, _self, _etag, _attachments, _ts).

Example output:

[
  {
    "id": "generated-id",
    "property1": "value1",
    "property2": "value2",
    "_rid": "...",
    "_self": "...",
    "_etag": "...",
    "_attachments": "...",
    "_ts": 1234567890
  }
]

Dependencies

  • External Service: Requires access to an Azure Cosmos DB account.
  • API Key/Connection String: You must provide a valid Azure Cosmos DB connection string.
  • n8n Configuration: No special configuration required beyond standard node setup.

Troubleshooting

  • Invalid Connection String:
    Error message: Authentication failed or invalid connection string.
    Resolution: Double-check your Azure Cosmos DB connection string for accuracy.

  • Malformed JSON in Item:
    Error message: Unexpected token ... in JSON at position ...
    Resolution: Ensure the "Item" property contains valid JSON.

  • Database/Container Not Found:
    Error message: Resource Not Found or similar.
    Resolution: Verify that the provided Database ID and Container ID exist in your Cosmos DB account.

  • Partition Key Issues:
    If your container requires a specific partition key, ensure your item includes the correct partition key field.

Links and References

Discussion