azure_cosmosdb
Creates or updates messages as JSON documents in Azure CosmosDB.
- Common
- Advanced
# Common config fields, showing default values
label: ""
azure_cosmosdb:
endpoint: https://localhost:8081 # No default (optional)
account_key: '!!!SECRET_SCRUBBED!!!' # No default (optional)
connection_string: '!!!SECRET_SCRUBBED!!!' # No default (optional)
database: testdb # No default (required)
container: testcontainer # No default (required)
partition_keys_map: root = "blobfish" # No default (required)
operation: Create
item_id: ${! json("id") } # No default (optional)
# All config fields, showing default values
label: ""
azure_cosmosdb:
endpoint: https://localhost:8081 # No default (optional)
account_key: '!!!SECRET_SCRUBBED!!!' # No default (optional)
connection_string: '!!!SECRET_SCRUBBED!!!' # No default (optional)
database: testdb # No default (required)
container: testcontainer # No default (required)
partition_keys_map: root = "blobfish" # No default (required)
operation: Create
patch_operations: [] # No default (optional)
patch_condition: from c where not is_defined(c.blobfish) # No default (optional)
auto_id: true
item_id: ${! json("id") } # No default (optional)
enable_content_response_on_write: true
When creating documents, each message must have the id property (case-sensitive) set (or use auto_id: true). It is the unique name that identifies the document, that is, no two documents share the same id within a logical partition. The id field must not exceed 255 characters. More details can be found here.
The partition_keys field must resolve to the same value(s) across the entire message batch.
Credentials
You can use one of the following authentication mechanisms:
- Set the
endpointfield and theaccount_keyfield - Set only the
endpointfield to use DefaultAzureCredential - Set the
connection_stringfield
Metadata
This component adds the following metadata fields to each message:
- activity_id
- request_charge
You can access these metadata fields using function interpolation.
Batching
CosmosDB limits the maximum batch size to 100 messages and the payload must not exceed 2MB (details here).
Examples
- Patch documents
Query documents from a container and patch them.
input:
azure_cosmosdb:
endpoint: http://localhost:8080
account_key: C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==
database: blobbase
container: blobfish
partition_keys_map: root = "AbyssalPlain"
query: SELECT * FROM blobfish
processors:
- mapping: |
root = ""
meta habitat = json("habitat")
meta id = this.id
- azure_cosmosdb:
endpoint: http://localhost:8080
account_key: C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==
database: testdb
container: blobfish
partition_keys_map: root = json("habitat")
item_id: ${! metadata("id").string() }
operation: Patch
patch_operations:
# Add a new /diet field
- operation: Add
path: /diet
value_map: root = json("diet")
# Remove the first location from the /locations array field
- operation: Remove
path: /locations/0
# Add new location at the end of the /locations array field
- operation: Add
path: /locations/-
value_map: root = "Challenger Deep"
# Return the updated document
enable_content_response_on_write: true