Azure CosmosDB Source
Provided by: "Apache Software Foundation"
Support Level for this Kamelet is: "Stable"
Consume Changes from a CosmosDB instance.
There are two different mechanism of authentication SHARED_ACCOUNT_KEY
and AZURE_IDENTITY
, you could specify with credentialType property. If you’re using SHARED_ACCOUNT_KEY
accountKey property will be needed.
In case of AZURE_IDENTITY
selection, the DefaultAzureCredential will attempt to authenticate via the following mechanisms in the following order enviroment, Workload Identity, Managed Identity, Azure Developer CLI, IntelliJ, Azure CLI and Azure Powershell.
Configuration Options
The following table summarizes the configuration options available for the azure-cosmosdb-source
Kamelet:
Property | Name | Description | Type | Default | Example |
---|---|---|---|---|---|
Container Name | Required The Azure Cosmos container name. | string | |||
Database Endpoint | Required Sets the Azure Cosmos database endpoint the component will connect to. | string | |||
Database Name | Required The Azure Cosmos database name. | string | |||
Account Key | The Azure Cosmos account Key. | string | |||
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 | ||
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 | ||
Credential Type | Determines the credential strategy to adopt. Enum values: * SHARED_ACCOUNT_KEY * AZURE_IDENTITY | string | SHARED_ACCOUNT_KEY | ||
Lease Container Name | Sets the lease database where the leaseContainerName will be stored. | string | |||
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
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 Environment 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.
apiVersion: camel.apache.org/v1
kind: Pipe
metadata:
name: azure-cosmosdb-source-pipe
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: azure-cosmosdb-source
properties:
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
-
Save the
azure-cosmosdb-source-pipe.yaml
file to your local drive, and then edit it as needed for your configuration. -
Run the source by using the following command:
kubectl apply -f azure-cosmosdb-source-pipe.yaml
Procedure for using the Kamel CLI
Configure and run the source by using the following command:
kamel bind channel:mychannel -p "source.containerName=The Container Name" -p "source.databaseEndpoint=The Database Endpoint" -p "source.databaseName=The Database Name" azure-cosmosdb-source
This command creates the Kamelet Pipe 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.
apiVersion: camel.apache.org/v1
kind: Pipe
metadata:
name: azure-cosmosdb-source-pipe
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: azure-cosmosdb-source
properties:
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
-
Save the
azure-cosmosdb-source-pipe.yaml
file to your local drive, and then edit it as needed for your configuration. -
Run the source by using the following command:
kubectl apply -f azure-cosmosdb-source-pipe.yaml
Procedure for using the Kamel CLI
Configure and run the source by using the following command:
kamel bind kafka.strimzi.io/v1beta1:KafkaTopic:my-topic -p "source.containerName=The Container Name" -p "source.databaseEndpoint=The Database Endpoint" -p "source.databaseName=The Database Name" azure-cosmosdb-source
This command creates the Kamelet Pipe in the current namespace on the cluster.