azure cosmosdb source Azure CosmosDB Source

Provided by: "Apache Software Foundation"

Support Level for this Kamelet is: "Preview"

Consume Changes from a CosmosDB instance

Configuration Options

The following table summarizes the configuration options available for the azure-cosmosdb-source Kamelet:

Property Name Description Type Default Example

accountKey

Account Key

Required The Azure Cosmos account Key.

string

containerName

Container Name

Required The Azure Cosmos container name.

string

databaseEndpoint

Database Endpoint

Required Sets the Azure Cosmos database endpoint the component will connect to.

string

databaseName

Database Name

Required The Azure Cosmos database name.

string

createLeaseContainerIfNotExists

Autocreate Lease Container

Sets if the component should create Cosmos lease container for the consumer automatically in case it doesn’t exist in Cosmos database.

boolean

false

createLeaseDatabaseIfNotExists

Autocreate Lease Database

Sets if the component should create Cosmos lease database for the consumer automatically in case it doesn’t exist in Cosmos account.

boolean

false

leaseContainerName

Lease Container Name

Sets the lease database where the leaseContainerName will be stored.

string

leaseDatabaseName

Lease Database Name

Sets the lease container which acts as a state storage and coordinates processing the change feed across multiple workers.

string

Dependencies

At runtime, the azure-cosmosdb-source Kamelet relies upon the presence of the following dependencies:

  • camel:azure-cosmosdb

  • camel:kamelet

  • camel:jackson

Usage

This section describes how you can use the azure-cosmosdb-source.

Knative source

You can use the azure-cosmosdb-source Kamelet as a Knative source by binding it to a Knative object.

azure-cosmosdb-source-binding.yaml
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
  name: azure-cosmosdb-source-binding
spec:
  source:
    ref:
      kind: Kamelet
      apiVersion: camel.apache.org/v1alpha1
      name: azure-cosmosdb-source
    properties:
      accountKey: The Account Key
      containerName: The Container Name
      databaseEndpoint: The Database Endpoint
      databaseName: The Database Name
  sink:
    ref:
      kind: Channel
      apiVersion: messaging.knative.dev/v1
      name: mychannel

Prerequisite

You have Camel K installed on the cluster.

Procedure for using the cluster CLI

  1. Save the azure-cosmosdb-source-binding.yaml file to your local drive, and then edit it as needed for your configuration.

  2. Run the source by using the following command:

    kubectl apply -f azure-cosmosdb-source-binding.yaml

Procedure for using the Kamel CLI

Configure and run the source by using the following command:

kamel bind azure-cosmosdb-source -p "source.accountKey=The Account Key" -p "source.containerName=The Container Name" -p "source.databaseEndpoint=The Database Endpoint" -p "source.databaseName=The Database Name" channel:mychannel

This command creates the KameletBinding in the current namespace on the cluster.

Kafka source

You can use the azure-cosmosdb-source Kamelet as a Kafka source by binding it to a Kafka topic.

azure-cosmosdb-source-binding.yaml
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
  name: azure-cosmosdb-source-binding
spec:
  source:
    ref:
      kind: Kamelet
      apiVersion: camel.apache.org/v1alpha1
      name: azure-cosmosdb-source
    properties:
      accountKey: The Account Key
      containerName: The Container Name
      databaseEndpoint: The Database Endpoint
      databaseName: The Database Name
  sink:
    ref:
      kind: KafkaTopic
      apiVersion: kafka.strimzi.io/v1beta1
      name: my-topic

Prerequisites

  • You’ve installed Strimzi.

  • You’ve created a topic named my-topic in the current namespace.

  • You have Camel K installed on the cluster.

Procedure for using the cluster CLI

  1. Save the azure-cosmosdb-source-binding.yaml file to your local drive, and then edit it as needed for your configuration.

  2. Run the source by using the following command:

    kubectl apply -f azure-cosmosdb-source-binding.yaml

Procedure for using the Kamel CLI

Configure and run the source by using the following command:

kamel bind azure-cosmosdb-source -p "source.accountKey=The Account Key" -p "source.containerName=The Container Name" -p "source.databaseEndpoint=The Database Endpoint" -p "source.databaseName=The Database Name" kafka.strimzi.io/v1beta1:KafkaTopic:my-topic

This command creates the KameletBinding in the current namespace on the cluster.