azure cosmosdb sink Azure CosmosDB Sink

Provided by: "Apache Software Foundation"

Support Level for this Kamelet is: "Stable"

Send Data to an Azure CosmosDB instance

In the headers, you can optionally set the itemPartitionKey / ce-itemPartitionKey property to specify the partition key for a specific item.

If you do not set the property in the header, you’ll need to use the static property itemPartitonKey.

Configuration Options

The following table summarizes the configuration options available for the azure-cosmosdb-sink 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

itemPartitionKey

Item Partition Key

Represents a partition key value in the Azure Cosmos DB database service. A partition key identifies the partition where the item is stored in.

string

Dependencies

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

  • camel:azure-cosmosdb

  • camel:kamelet

  • camel:jackson

  • camel:core

Camel Jbang usage

Prerequisites

  • You’ve installed Jbang.

  • You have executed the following command:

jbang app install camel@apache/camel

Supposing you have a file named route.yaml with this content:

- route:
    from:
      uri: "kamelet:timer-source"
      parameters:
        period: 10000
        message: 'test'
      steps:
        - to:
            uri: "kamelet:log-sink"

You can now run it directly through the following command

camel run route.yaml

Camel K Enviroment Usage

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

Knative sink

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

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

Prerequisite

You have Camel K installed on the cluster.

Procedure for using the cluster CLI

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

  2. Run the sink by using the following command:

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

Procedure for using the Kamel CLI

Configure and run the sink by using the following command:

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

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

Kafka sink

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

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

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-sink-binding.yaml file to your local drive, and then edit it as needed for your configuration.

  2. Run the sink by using the following command:

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

Procedure for using the Kamel CLI

Configure and run the sink by using the following command:

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

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