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

The Azure Cosmos account Key.

string

containerName *

Container Name

The Azure Cosmos container name.

string

databaseEndpoint *

Database Endpoint

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

string

databaseName *

Database Name

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

Fields marked with (*) are mandatory.

Usage

This section summarizes how the azure-cosmosdb-source can be used in various contexts.

Knative Source

The azure-cosmosdb-source Kamelet can be used as 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

Make sure you have Camel K installed into the Kubernetes cluster you’re connected to.

Save the azure-cosmosdb-source-binding.yaml file into your hard drive, then configure it according to your needs.

You can run the source using the following command:

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

Dependencies

The Kamelet needs the following dependencies:

  • camel:azure-cosmosdb

  • camel:kamelet

  • camel:jackson

Binding to Knative using the Kamel CLI:

The procedure described above can be simplified into a single execution of the kamel bind 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 will create the KameletBinding under the hood and apply it to the current namespace in the cluster.

Kafka Source

The azure-cosmosdb-source Kamelet can be used as 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

Ensure that you’ve installed Strimzi and created a topic named my-topic in the current namespace. Make also sure you have Camel K installed into the Kubernetes cluster you’re connected to.

Save the azure-cosmosdb-source-binding.yaml file into your hard drive, then configure it according to your needs.

You can run the source using the following command:

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

Binding to Kafka using the Kamel CLI:

The procedure described above can be simplified into a single execution of the kamel bind 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 will create the KameletBinding under the hood and apply it to the current namespace in the cluster.

Kamelet source file

Have a look at the following link: