Cosmos DB Query

Cosmos DB Query

Certified

Run one Cosmos query

Executes a Cosmos SQL query with optional partition scope or feed range and returns the matching documents.

yaml
type: io.kestra.plugin.azure.storage.cosmosdb.Query
yaml
id: azure_storage_cosmos_query
namespace: company.team

tasks:
  - id: query
    type: io.kestra.plugin.azure.storage.cosmosdb.Query
    endpoint: "https://yourcosmosaccount.documents.azure.com"
    databaseId: your_data_base_id
    containerId: your_container_id
    tenantId: "{{ secret('AZURE_TENANT_ID') }}"
    clientId: "{{ secret('AZURE_CLIENT_ID') }}"
    clientSecret: "{{ secret('AZURE_CLIENT_SECRET') }}"
    query: "SELECT * FROM c WHERE c.region = 'europe'"
    partitionKeyDefinition:
      paths: ["/region"]
      kind: HASH
      version: V2
    partitionKey:
      region: europe
Installation

Our standard Docker images already include this plugin. If you use a -slim image or another setup, install it with the following command:

kestractl plugins get io.kestra.plugin:plugin-azure --compatible-for $KESTRA_VERSION

For kestractl, use your Kestra version with --compatible-for, or specify an exact plugin version.

For Kestra CLI, replace LATEST with a specific version or version range to pin the plugin version.

Properties

Container ID

Container (collection) name within the database; must already exist.

Database ID

Target database name inside the account; required.

SQL query string

Azure AD tenant ID (GUID)

Assets this task consumes as inputs or produces as outputs, for lineage tracking and the asset graph (Enterprise Edition). A flow declaring this property on a task is rejected in the open-source edition.

Definitions
assetFailureBehaviorstring
Possible Values
IGNOREFAILWARN

Asset failure behavior

Behavior applied to the task state when a declared asset fails to render, emit, or be persisted (e.g. a lock conflict): FAIL escalates it to FAILED, WARN (default) warns it if it would otherwise succeed, IGNORE leaves the state untouched.

enableAutobooleanstring

Whether to auto-register assets referenced dynamically at runtime that are not statically declared in inputs or outputs.

inputsarray

The assets consumed as inputs.

id*string
Min length1
typestring
outputs

The assets produced as outputs.

id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*string
Min length1

Custom asset type

descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150

Client ID of the Azure AD application

Application (client) ID used for service principal authentication.

Client secret for the Azure AD application

Secret value associated with the client ID; store in a Kestra secret.

Cosmos connection string

Full connection string from Azure portal; overrides endpoint and Azure AD credentials when set.

DefaultSession
Possible Values
STRONGBOUNDED_STALENESSSESSIONEVENTUALCONSISTENT_PREFIX

Choose request consistency

Consistency level sent to Cosmos; defaults to SESSION.

Defaulttrue

Return payload on writes

When true (default), write responses include the document body; set false to reduce payload size.

Cosmos account endpoint

Base account URL (e.g. https://.documents.azure.com). Required when connectionString is absent. A localhost or 127.0.0.1 endpoint, such as a Cosmos emulator, is reached in gateway mode.

SubTypestring

Regions to exclude

Regions to avoid for this query (e.g. "East US"). If all preferred regions are excluded, Cosmos falls back to the account primary region.

Feed range partition key values

Map of partition key path to value used to build a feed range (e.g. { "country": "US" }); requires partitionKeyDefinition and is mutually exclusive with partitionKey.

Partition key values

Map of partition key path to value (e.g. { "country": "US" } for a /country key); requires partitionKeyDefinition.

Partition key definition (paths, kind, version)

Partition key schema (paths, kind, version); required with partitionKey or feedRangePartitionKey to build the correct PartitionKey.

Definitions
kind*string
Possible Values
HASHRANGEMULTI_HASH

Partitioning algorithm

Partition strategy, typically HASH, matching the container configuration.

paths*array
SubTypestring

Partition key paths

Ordered item property paths (e.g. [/pk]); each must start with '/'.

version*string
Possible Values
V1V2

Partition key definition version

Version used when the container was created; choose the same value.

PEM-encoded certificate content for client authentication

PEM text for certificate-based auth; alternative to clientSecret.

SubTypeobject

Query results