The Azure Cosmos DB actions let you read, write, and manage documents and databases in Azure Cosmos DB directly from your workflows. All actions authenticate using an Azure AD service principal and communicate with the Cosmos DB data plane.
Get an item
This action reads a single document by ID from an Azure Cosmos DB container using the Azure Cosmos DB - Get Document REST API.
Input | Type | Description |
|---|---|---|
| String | Required. Azure AD app (client) ID. Must be passed as a secret. See how to register an Azure app. |
| String | Required. Azure AD client secret. Must be passed as a secret. See how to register an Azure app. |
| String | Required. The Azure AD tenant identifier. Can be passed as a secret. |
| String | Required. The Cosmos DB account name. For example, |
| String | Required. The database identifier. For example, |
| String | Required. The container (collection) identifier. For example, |
| String | Required. The document |
| String | Required. The partition key value for the document. For example, |
| List | Optional. A list of selectors used to extract specific values from the response. For example, |
Output | Type | Description |
|---|---|---|
| Boolean |
|
| String | Failure reason as a message. |
| Object | The document body. For more information, see the Azure Cosmos DB - Get Document REST API. |
| String | The ETag of the returned document, used for optimistic concurrency control. |
| String | The request units (RU) consumed by the operation. |
name: cosmosGetItemWorkflowdescription: ''steps: - name: get_item type: action action: azure.cosmos.getItem version: 1 inputs: clientId: ${{ :secrets:azure-client-id }} clientSecret: ${{ :secrets:azure-client-secret }} tenantId: ${{ :secrets:azure-client-tenant }} accountName: my-cosmos-account databaseId: TestDb collectionId: Items itemId: "121" partitionKey: beta selectors: - name: item expression: ".response" next: log_result - name: log_result type: action action: newrelic.ingest.sendLogs version: 1 inputs: logs: - message: 'azure.cosmos.getItem result: ${{ .steps.get_item.outputs | tostring }}' next: endCreate an item
This action creates a new document in an Azure Cosmos DB container using the Azure Cosmos DB - Create Document REST API.
Input | Type | Description |
|---|---|---|
| String | Required. Azure AD app (client) ID. Must be passed as a secret. See how to register an Azure app. |
| String | Required. Azure AD client secret. Must be passed as a secret. See how to register an Azure app. |
| String | Required. The Azure AD tenant identifier. Can be passed as a secret. |
| String | Required. The Cosmos DB account name. For example, |
| String | Required. The database identifier. For example, |
| String | Required. The container (collection) identifier. For example, |
| String | Required. The partition key value for the new document. Must match the document's partition key property value. For example, |
| Map | Required. The document to create. Must include the partition key property (for example, |
| List | Optional. A list of selectors used to extract specific values from the response. For example, |
Output | Type | Description |
|---|---|---|
| Boolean |
|
| String | Failure reason as a message. |
| Object | The created document as stored, including system fields. For more information, see the Azure Cosmos DB - Create Document REST API. |
| String | The ETag of the created document, used for optimistic concurrency control. |
| String | The request units (RU) consumed by the operation. |
name: cosmosCreateItemWorkflowdescription: ''steps: - name: create_item type: action action: azure.cosmos.createItem version: 1 inputs: clientId: ${{ :secrets:azure-client-id }} clientSecret: ${{ :secrets:azure-client-secret }} tenantId: ${{ :secrets:azure-client-tenant }} accountName: my-cosmos-account databaseId: TestDb collectionId: Items partitionKey: beta item: id: "423" pk: beta name: created-by-workflow category: demo value: 42 selectors: - name: newId expression: .response.id next: log_result - name: log_result type: action action: newrelic.ingest.sendLogs version: 1 inputs: logs: - message: 'azure.cosmos.createItem succeeded=${{ .steps.create_item.outputs.success }} newId=${{ .steps.create_item.outputs.newId }}' next: endUpdate an item
This action replaces or upserts a document in an Azure Cosmos DB container using the Azure Cosmos DB - Replace Document REST API. By default (upsert: false) the document must already exist. Set upsert: true to create the document if it does not exist.
Input | Type | Description |
|---|---|---|
| String | Required. Azure AD app (client) ID. Must be passed as a secret. See how to register an Azure app. |
| String | Required. Azure AD client secret. Must be passed as a secret. See how to register an Azure app. |
| String | Required. The Azure AD tenant identifier. Can be passed as a secret. |
| String | Required. The Cosmos DB account name. For example, |
| String | Required. The database identifier. For example, |
| String | Required. The container (collection) identifier. For example, |
| String | Required. The document |
| String | Required. The partition key value for the document. For example, |
| Map | Required. The full replacement document. Must include the same |
| Boolean | Optional. When |
| List | Optional. A list of selectors used to extract specific values from the response. For example, |
Output | Type | Description |
|---|---|---|
| Boolean |
|
| String | Failure reason as a message. |
| Object | The stored document after the write. For more information, see the Azure Cosmos DB - Replace Document REST API. |
| String | The ETag of the stored document after the write, used for optimistic concurrency control. |
| String | The request units (RU) consumed by the operation. |
name: cosmosUpdateItemWorkflowdescription: ''steps: - name: update_item type: action action: azure.cosmos.updateItem version: 1 inputs: clientId: ${{ :secrets:azure-client-id }} clientSecret: ${{ :secrets:azure-client-secret }} tenantId: ${{ :secrets:azure-client-tenant }} accountName: my-cosmos-account databaseId: TestDb collectionId: Items itemId: "323" partitionKey: beta upsert: false item: id: "323" pk: beta name: updated-by-workflow category: demo value: 43 selectors: - name: updatedId expression: .response.id - name: eTag expression: .response._etag next: log_result - name: log_result type: action action: newrelic.ingest.sendLogs version: 1 inputs: logs: - message: 'azure.cosmos.updateItem succeeded=${{ .steps.update_item.outputs.success }} updatedId=${{ .steps.update_item.outputs.updatedId }} eTag=${{ .steps.update_item.outputs.eTag }}' next: endDelete an item
This action deletes a document from an Azure Cosmos DB container using the Azure Cosmos DB - Delete Document REST API.
Input | Type | Description |
|---|---|---|
| String | Required. Azure AD app (client) ID. Must be passed as a secret. See how to register an Azure app. |
| String | Required. Azure AD client secret. Must be passed as a secret. See how to register an Azure app. |
| String | Required. The Azure AD tenant identifier. Can be passed as a secret. |
| String | Required. The Cosmos DB account name. For example, |
| String | Required. The database identifier. For example, |
| String | Required. The container (collection) identifier. For example, |
| String | Required. The document |
| String | Required. The partition key value for the document. Must match the document's partition key property value. For example, |
| List | Optional. A list of selectors used to extract specific values from the response. For example, |
Output | Type | Description |
|---|---|---|
| Boolean |
|
| String | Failure reason as a message. |
| Object | The delete response. Typically empty on success. Use a selector such as |
| String | The request units (RU) consumed by the operation. |
name: cosmosDeleteItemWorkflowdescription: ''steps: - name: delete_item type: action action: azure.cosmos.deleteItem version: 1 inputs: clientId: ${{ :secrets:azure-client-id }} clientSecret: ${{ :secrets:azure-client-secret }} tenantId: ${{ :secrets:azure-client-tenant }} accountName: my-cosmos-account databaseId: TestDb collectionId: Items itemId: "121" partitionKey: beta selectors: - name: statusCode expression: ".response.status_code" next: log_result - name: log_result type: action action: newrelic.ingest.sendLogs version: 1 inputs: logs: - message: 'azure.cosmos.deleteItem result: ${{ .steps.delete_item.outputs | tostring }}' next: endDescribe a database
This action retrieves metadata for an Azure Cosmos DB database using the Azure Cosmos DB - Get Database REST API.
Input | Type | Description |
|---|---|---|
| String | Required. Azure AD app (client) ID. Must be passed as a secret. See how to register an Azure app. |
| String | Required. Azure AD client secret. Must be passed as a secret. See how to register an Azure app. |
| String | Required. The Azure AD tenant identifier. Can be passed as a secret. |
| String | Required. The Cosmos DB account name. For example, |
| String | Required. The database to describe. For example, |
| List | Optional. A list of selectors used to extract specific values from the response. For example, |
Output | Type | Description |
|---|---|---|
| Boolean |
|
| String | Failure reason as a message. |
| Object | The database resource, including fields such as |
| String | The ETag of the database resource. |
name: cosmosDescribeDatabaseWorkflowdescription: ''steps: - name: describeDatabase type: action action: azure.cosmos.describeDatabase version: 1 inputs: clientId: ${{ :secrets:azure-client-id }} clientSecret: ${{ :secrets:azure-client-secret }} tenantId: ${{ :secrets:azure-client-tenant }} accountName: my-cosmos-account databaseId: TestDb selectors: - name: database expression: ".response" - name: id expression: ".response.id" - name: eTag expression: ".eTag" - name: logResult type: action action: newrelic.ingest.sendLogs version: 1 inputs: logs: - message: 'azure.cosmos.describeDatabase database: ${{ .steps.describeDatabase.outputs.database | tostring }}' attributes: success: ${{ .steps.describeDatabase.outputs.success }} id: ${{ .steps.describeDatabase.outputs.id }} eTag: ${{ .steps.describeDatabase.outputs.eTag }} next: end