# Azure CosmosDB

Creates or updates messages as JSON documents in [Azure CosmosDB](https://learn.microsoft.com/en-us/azure/cosmos-db/introduction).

## Configuration

| Name               | Type                | Optional | Secret | Description                                                                                                                                                                                                                                                                       |
| ------------------ | ------------------- | -------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| connection_string  | string              | no       | no     | A CosmosDB connection string.                                                                                                                                                                                                                                                     |
| database           | string              | no       | no     | The name of the database to query.                                                                                                                                                                                                                                                |
| container          | string              | no       | no     | The name of the container to query.                                                                                                                                                                                                                                               |
| partition_keys_map | string              | no       | no     | A Bloblang mapping which should evaluate to a single partition key value or an array of partition key values of type string, integer or boolean. Currently, hierarchical partition keys are not supported so only one value may be provided.                                      |
| operation          | string              | yes      | no     | The operation to perform on the document. The value should be one of `Create`, `Delete`, `Patch`, `Replace` or `Upsert`. The value defaults to `Create`.                                                                                                                          |
| patch_operations   | \[]patch_operations | yes      | no     | A list of patch operations to apply to the document. This field is only used when the operation is set to `Patch`.                                                                                                                                                                |
| patch_condition    | string              | yes      | no     | Patch operation condition. This field supports interpolation functions. This field is only used when the operation is set to `Patch`.                                                                                                                                             |
| auto_id            | bool                | yes      | no     | Whether to automatically generate an ID for the document if one is not provided. If the `id` field is already set, then it will not be overwritten. Setting this to `false` can improve performance, since the messages will not have to be parsed. The value defaults to `true`. |
| item_id            | expression          | no       | no     | ID of item to replace or delete. Only used by the Replace and Delete operations. This field supports interpolation functions.                                                                                                                                                     |
| max_in_flight      | int                 | yes      | no     | The maximum number of messages to have in flight at any given time. The value defaults to `64`.                                                                                                                                                                                   |

### Patch operations

| Name      | Type   | Optional | Secret | Description                                                                                                                                         |
| --------- | ------ | -------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| operation | string | yes      | no     | The operation to perform on the document. The value should be one of `Add`, `Increment`, `Remove`, `Replace` or `Set`. The value defaults to `Add`. |
| path      | string | yes      | no     | The path to the field to apply the operation to.                                                                                                    |
| value_map | string | yes      | no     | A Bloblang mapping which should evaluate to the value to apply to the field.                                                                        |
