# CosmosDB

Category: Azure
|
Runtime: 0.9+
|
Available: Free

# Overview

CosmosDB node enables the connection with CosmosDB database service in Azure.

# Setup

# Prerequisites

For CosmosDB node to work properly, you need to have a valid subscription of Azure account (opens new window). Ensure to have the connection details and Security key from Azure portal for the node to connect with the CosmosDB database.

# Installation

To install the node from designer:

  1. Go to Add more nodes option on the palette section.
  2. Check for the CosmosDB node and click install.
  3. Once installed, the designer is required to be restarted.

To install the node from CLI:

  1. Go to your project workspace where you can see your package.json file.
  2. Run the below give npm command.
    npm i @kumologica/kumologica-contrib-cosmosdb

# Technical Details

Properties

  • Host (Required)
    The database host name.
  • Port (Required)
    The database port.
  • Database (Required)
    The name of the database.
  • Host (Required)
    Option for encoding or decoding a message property.
  • Container (Required)
    The name of the container within the database. Similar to collections in nosql databases
  • Security Key (Required)
    The security key for connecting to Azure Cosmos database.
  • ID Value (Required)
    The primary key value. In Azure Cosmos database containers, the primary key is always named as: id. For Create operation, if this value is left blank, the id will be auto-generated. Required for other operations.
  • Partition Key Name (Required)
    Name of the partition key for the Azure Cosmos database container.
  • Partition Key Value (Required)
    Value for the partition key for the Azure Cosmos database container
  • Item Fields (Required)
    Values for the item, specified as key/value pairs. Add additional key/value attribute pairs by clicking on the +Add button towards the bottom.

Note
512 mb is the minimum memory requirement for your AWS lambda deployment when using CosmosDB node.

Supported Operations

  • Create
    Create an item in the Azure Cosmos database container.
  • Update
    Based on id, update an existing item in the Azure Cosmos database container by updating existing keys, or by adding new key/value pairs.
  • Replace
    Based on id, completely replace an existing item in the Azure Cosmos database container.
  • Read
    Read an item based on its id.
  • Delete
    Delete an item based on its id.
  • Query
    Execute an SQL type query to fetch items from Azure Cosmos database container.

Throws

CosmosDB node throws the following exception.

  • CosmosDBNodeError - When any kind of error occurs during the execution of the operations, including errors related to connectivity to the Azure Cosmos database.

Returns

If the operation is Read or Query, on successful execution, the result of the query execution will be set to msg.payload and be available for further processing.