Azure Cosmos DB

Azure Cosmos DB is a globally distributed multi-model database service designed to enable you to elastically and independently scale throughput and storage across any number of geographical regions with a comprehensive SLA.

This connector is available in the following products and regions:

Service Class Regions
Logic Apps Standard All Logic Apps regions and Integration Service Environments (ISEs)
Power Automate Premium All Power Automate regions
Connector Metadata
Publisher Microsoft

To use this integration, you will need a Cosmos DB SQL API account configured in the Azure Portal. Note that Mongo DB API accounts are not currently supported.

Once the SQL API account is created, provide the account ID (without 'documents.azure.com') when creating a connection with the Azure Cosmos DB connector.

Known Issues and Limitations

  • The maximum size of a document that is supported by the DocumentDB (Azure Cosmos DB) connector is 2 MB.
  • The Azure Cosmos DB limitations are documented here.
  • The "Partition key value" must be provided according to its type. For example string value must be placed between qoutes like "string value", but numeric value must be without them, like 123
  • The "Partition key value" is required for queries with ORDER BY, DISTINCT, etc, that run on partitioned collections.
  • The Azure Cosmos DB connector using Azure Cosmos DB .NET SDK for SQL API, release 2.9.2. The SDK is only used for "Query documents V2" action.

Creating a connection

To connect your account, you will need the following information:

Name Type Description
Account ID string

Name of the account without 'documents.azure.com' part

Access Key to your Azure Cosmos DB account securestring

Primary or Secondary Key

Throttling Limits

Name Calls Renewal Period
API calls per connection150060 seconds

Actions

Create or update document

Create or update document. When creating a document in DocumentDB, the body must include an id property.

Create stored procedure

Create stored procedure.

Delete a document

Delete a document.

Delete stored procedure

Delete stored procedure.

Execute stored procedure

Execute stored procedure in specified collection.

Get a document

Get a document.

Get all documents

Get all documents.

Get all documents V2

Get all documents V2.

Get stored procedures

Get stored procedures in the specified collection.

Query documents [DEPRECATED]

This action has been deprecated. Please use Query documents V3 instead.

Query documents.

Query documents V2

Query documents V2.

Query documents V3

Query documents V3.

Replace a document

Replace a document.

Replace stored procedure

Replace stored procedure.

Create or update document

Create or update document. When creating a document in DocumentDB, the body must include an id property.

Parameters

Name Key Required Type Description
Partition key value
x-ms-documentdb-raw-partitionkey string

The partition key value for the requested document or attachment operation.

Max Item Count
x-ms-max-item-count number

An integer indicating the maximum number of items to be returned per page.

Continuation Token
x-ms-continuation string

A string token returned for queries and read-feed operations if there are more results to be read.

Consistency Level
x-ms-consistency-level string

This is the consistency level override. The valid values are: Strong, Bounded, Session, or Eventual (in order of strongest to weakest).

Session Token
x-ms-session-token string

A string token used with session level consistency.

Activity id
x-ms-activity-id string

A client supplied identifier for the operation, which will be echoed in the server response.

IsUpsert
x-ms-documentdb-is-upsert boolean

If set to true, the document will be replaced if it exists else created.

Pre-Trigger
x-ms-documentdb-pre-trigger-include string

Comma-separated list of trigger names to run before the document operation is executed.

Post-Trigger
x-ms-documentdb-post-trigger-include string

Comma-separated list of trigger names to run after the document operation is executed.

Database ID
databaseId True string

The name of the database.

Collection ID
collectionId True string

The name of the collection.

API version
x-ms-version string

API version.

Returns

Create stored procedure

Create stored procedure.

Parameters

Name Key Required Type Description
Database ID
databaseId True string

The name of the database.

Collection ID
collectionId True string

The name of the collection.

Function definition
body string

Function that defines the stored procedure, e.g. 'function(params){ ... }'

id
id string

New id of the stored procedure.

API version
x-ms-version string

API version.

Returns

Delete a document

Delete a document.

Parameters

Name Key Required Type Description
Partition key value
x-ms-documentdb-raw-partitionkey string

The partition key value for the requested document or attachment operation.

Max Item Count
x-ms-max-item-count number

An integer indicating the maximum number of items to be returned per page.

Continuation Token
x-ms-continuation string

A string token returned for queries and read-feed operations if there are more results to be read.

Consistency Level
x-ms-consistency-level string

This is the consistency level override. The valid values are: Strong, Bounded, Session, or Eventual (in order of strongest to weakest).

Session Token
x-ms-session-token string

A string token used with session level consistency.

Activity id
x-ms-activity-id string

A client supplied identifier for the operation, which will be echoed in the server response.

Pre-Trigger
x-ms-documentdb-pre-trigger-include string

Comma-separated list of trigger names to run before the document is deleted.

Post-Trigger
x-ms-documentdb-post-trigger-include string

Comma-separated list of trigger names to run after the document id deleted.

Database ID
databaseId True string

The name of the document.

Collection ID
collectionId True string

The name of the collection.

Document ID
documentId True string

The identifier of the document.

API version
x-ms-version string

API version.

Delete stored procedure

Delete stored procedure.

Parameters

Name Key Required Type Description
Database ID
databaseId True string

The name of the database.

Collection ID
collectionId True string

The name of the collection.

Sproc ID
sprocId True string

The name of the stored procedure.

API version
x-ms-version string

API version.

Returns

response
string

Execute stored procedure

Execute stored procedure in specified collection.

Parameters

Name Key Required Type Description
Database ID
databaseId True string

The name of the database.

Collection ID
collectionId True string

The name of the collection.

Partition key value
x-ms-documentdb-raw-partitionkey string

The partition key value for the requested document or attachment operation.

Sproc ID
sprocId True string

The name of the stored procedure.

Parameters for the stored procedure
parameters string

Specify valid JSON for the parameters of the stored procedure, e.g. ["param1", "param2"].

API version
x-ms-version string

API version.

Returns

Get a document

Get a document.

Parameters

Name Key Required Type Description
Partition key value
x-ms-documentdb-raw-partitionkey string

The partition key value for the requested document or attachment operation.

Max Item Count
x-ms-max-item-count number

An integer indicating the maximum number of items to be returned per page.

Continuation Token
x-ms-continuation string

A string token returned for queries and read-feed operations if there are more results to be read.

Consistency Level
x-ms-consistency-level string

This is the consistency level override. The valid values are: Strong, Bounded, Session, or Eventual (in order of strongest to weakest).

Session Token
x-ms-session-token string

A string token used with session level consistency.

Activity id
x-ms-activity-id string

A client supplied identifier for the operation, which will be echoed in the server response.

Database ID
databaseId True string

The name of the database.

Collection ID
collectionId True string

The name of the collection.

Document ID
documentId True string

The identifier for the document.

API version
x-ms-version string

API version.

Returns

response
object

Get all documents

Get all documents.

Parameters

Name Key Required Type Description
Partition key value
x-ms-documentdb-raw-partitionkey string

The partition key value for the requested document or attachment operation.

Max Item Count
x-ms-max-item-count number

An integer indicating the maximum number of items to be returned per page.

Continuation Token
x-ms-continuation string

A string token returned for queries and read-feed operations if there are more results to be read.

Consistency Level
x-ms-consistency-level string

This is the consistency level override. The valid values are: Strong, Bounded, Session, or Eventual (in order of strongest to weakest).

Session Token
x-ms-session-token string

A string token used with session level consistency.

Activity id
x-ms-activity-id string

A client supplied identifier for the operation, which will be echoed in the server response.

Database ID
databaseId True string

The name of the database.

Collection ID
collectionId True string

The name of the collection.

API version
x-ms-version string

API version.

Returns

Get all documents V2

Get all documents V2.

Parameters

Name Key Required Type Description
Database ID
databaseId True string

The name of the database.

Collection ID
collectionId True string

The name of the collection.

Partition key value
partitionKey string

If empty, all partitions will be used to search for documents.

Max Item Count
maxItemCount integer

Maximum number of items to be returned.

Continuation Token
continuationToken string

A token to fetch additional results.

Consistency Level
consistencyLevel string

Consistency level required for the feed (query/read feed) operation.

Session Token
sessionToken string

The session token for use with session consistency.

Returns

Array of documents that match the requested query and the related metadata.

Get stored procedures

Get stored procedures in the specified collection.

Parameters

Name Key Required Type Description
Database ID
databaseId True string

The name of the database.

Collection ID
collectionId True string

The name of the collection.

API version
x-ms-version string

API version.

Returns

Query documents [DEPRECATED]

This action has been deprecated. Please use Query documents V3 instead.

Query documents.

Parameters

Name Key Required Type Description
Partition key value
x-ms-documentdb-raw-partitionkey string

The partition key value for the requested document or attachment operation.

Max Item Count
x-ms-max-item-count number

An integer indicating the maximum number of items to be returned per page.

Continuation Token
x-ms-continuation string

A string token returned for queries and read-feed operations if there are more results to be read.

Enable Cross Partition
x-ms-documentdb-query-enablecrosspartition boolean

If the collection is partitioned, this must be set to True to allow execution across multiple partitions.

Consistency Level
x-ms-consistency-level string

This is the consistency level override. The valid values are: Strong, Bounded, Session, or Eventual (in order of strongest to weakest).

Session Token
x-ms-session-token string

A string token used with session level consistency.

Activity id
x-ms-activity-id string

A client supplied identifier for the operation, which will be echoed in the server response.

Database ID
databaseId True string

The name of the database

Collection ID
collectionId True string

The name of the collection.

query
query string

The partition key value for the requested document or attachment operation.

Returns

Query documents V2

Query documents V2.

Parameters

Name Key Required Type Description
Database ID
databaseId True string

The name of the database.

Collection ID
collectionId True string

The name of the collection.

QueryText
QueryText string

SQL Syntax Query over documents

Partition key value
partitionKey string

Partition key value.

Continuation Token
continuationToken string

A token to fetch additional results from the operation.

Returns

Array of documents that match the requested query and the related metadata.

Query documents V3

Query documents V3.

Parameters

Name Key Required Type Description
Database ID
databaseId True string

The name of the database.

Collection ID
collectionId True string

The name of the collection.

SQL Syntax Query
queryText True string

SQL query.

Partition key value
partitionKey string

If empty, all partitions will be used to search for documents.

Max Item Count
maxItemCount integer

Maximum number of items to be returned.

Continuation Token
continuationToken string

A token to fetch additional results.

Enable Cross Partition
enableCrossPartition boolean

Indicates whether user are enabled to send more than one request to execute the query.

Consistency Level
consistencyLevel string

Consistency level required for the feed (query/read feed) operation.

Session Token
sessionToken string

The session token for use with session consistency.

Returns

Array of documents that match the requested query and the related metadata.

Replace a document

Replace a document.

Parameters

Name Key Required Type Description
Partition key value
x-ms-documentdb-raw-partitionkey string

The partition key value for the requested document or attachment operation.

Max Item Count
x-ms-max-item-count number

An integer indicating the maximum number of items to be returned per page.

Continuation Token
x-ms-continuation string

A string token returned for queries and read-feed operations if there are more results to be read.

Consistency Level
x-ms-consistency-level string

This is the consistency level override. The valid values are: Strong, Bounded, Session, or Eventual (in order of strongest to weakest).

Session Token
x-ms-session-token string

A string token used with session level consistency.

Activity id
x-ms-activity-id string

A client supplied identifier for the operation, which will be echoed in the server response.

Pre-Trigger
x-ms-documentdb-pre-trigger-include string

Comma-separated list of trigger names to run before replacing the document.

Post-Trigger
x-ms-documentdb-post-trigger-include string

Comma-separated list of trigger names to run after replacing the document.

Database ID
databaseId True string

The name of the database.

Collection ID
collectionId True string

The name of the collection.

Document ID
documentId True string

The identifier of the document.

API version
x-ms-version string

API version.

Returns

Replace stored procedure

Replace stored procedure.

Parameters

Name Key Required Type Description
Database ID
databaseId True string

The name of the database.

Collection ID
collectionId True string

The name of the collection.

Sproc ID
sprocId True string

The name of the stored procedure.

Function definition
body string

Function that defines the stored procedure, e.g. 'function(params){ ... }'

id
id string

Id of the existing stored procedure.

API version
x-ms-version string

API version.

Returns

Definitions

QueryDocumentsResponse

Array of documents that match the requested query and the related metadata.

Name Path Type Description
Documents
Documents array of ObjectWithoutType

Array of documents that match the request.

Number of Documents
_count integer

Number of documents.

Activity ID
ActivityId string

Azure Cosmos DB service activity ID.

DocumentsCollection

Array of documents that match the requested query and the related metadata.

Name Path Type Description
Documents
value array of ObjectWithoutType
Continuation Token
ContinuationToken string
Number of Documents
Count integer
Request Charge
RequestCharge double
Session Token
SessionToken string
Activity Id
ActivityId string

postDocumentsResponse

Name Path Type Description
_rid
_rid string
_ts
_ts integer
_self
_self string
_etag
_etag string
_attachments
_attachments string
id
id string

putDocumentResponse

Name Path Type Description
_rid
_rid string
id
id string

getDocumentsResponse

Name Path Type Description
_rid
_rid string
Documents
Documents array of object

queryResponse

Name Path Type Description
_rid
_rid string
_count
_count number
Documents
Documents array of

getStoredProceduresResponse

Name Path Type Description
_count
_count integer

_count

_rid
_rid string

_rid

StoredProcedures
StoredProcedures array of object

StoredProcedures

_etag
StoredProcedures._etag string

_etag

_rid
StoredProcedures._rid string

_rid

_self
StoredProcedures._self string

_self

_ts
StoredProcedures._ts integer

_ts

body
StoredProcedures.body string

body

id
StoredProcedures.id string

id

createStoredProcedureResponse

Name Path Type Description
_etag
_etag string

_etag

_rid
_rid string

_rid

_self
_self string

_self

_ts
_ts integer

_ts

body
body string

body

id
id string

id

ObjectWithoutType

string

This is the basic data type 'string'.

object

This is the type 'object'.