This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kamelets-examples.git
The following commit(s) were added to refs/heads/main by this push:
new e9c76bc Added an Azure Servicebus example with Terraform
e9c76bc is described below
commit e9c76bc805b92bf6968dda8aa635418cfdd129f9
Author: Andrea Cosentino <[email protected]>
AuthorDate: Wed Feb 21 15:13:31 2024 +0100
Added an Azure Servicebus example with Terraform
Signed-off-by: Andrea Cosentino <[email protected]>
---
jbang/azure-servicebus/README.adoc | 79 ++++++++++++++++++++++
jbang/azure-servicebus/application.properties | 1 +
.../azure-servicebus/azure-servicebus-to-log.yaml | 31 +++++++++
jbang/azure-servicebus/terraform/main.tf | 29 ++++++++
jbang/azure-servicebus/terraform/outputs.tf | 4 ++
jbang/azure-servicebus/terraform/variables.tf | 5 ++
.../timer-to-azure-servicebus.yaml | 30 ++++++++
7 files changed, 179 insertions(+)
diff --git a/jbang/azure-servicebus/README.adoc
b/jbang/azure-servicebus/README.adoc
new file mode 100644
index 0000000..096b0e6
--- /dev/null
+++ b/jbang/azure-servicebus/README.adoc
@@ -0,0 +1,79 @@
+== Sending message to Servicebus and consume them
+
+In this sample you'll use the Azure Servicebus source and sink Kamelet based
on camel-azure-servicebus component.
+
+=== Install JBang
+
+First install JBang according to https://www.jbang.dev
+
+When JBang is installed then you should be able to run from a shell:
+
+[source,sh]
+----
+$ jbang --version
+----
+
+This will output the version of JBang.
+
+To run this example you can either install Camel on JBang via:
+
+[source,sh]
+----
+$ jbang app install camel@apache/camel
+----
+
+Which allows to run CamelJBang with `camel` as shown below.
+
+=== Terraform steps
+
+[source,sh]
+----
+$ cd terraform/
+----
+
+First of all init terraform
+
+[source,sh]
+----
+$ terraform init
+----
+
+Then run the command to apply your configuration to your Azure account
+
+[source,sh]
+----
+$ terraform apply -var="services_bus_namespace_name=<namespace_name>"
-var="resource_group_name=<resource_name>" -var="location=<location>"
-var="messages_queue_name=<queue_name>" -out tfout.log
+----
+
+Correctly populating the various field for your needs
+
+Once the process will complete you'll get a sensitive output for the primary
connection String
+
+You're now able to read the sensitive data with
+
+[source,sh]
+----
+terraform output --raw messages_queue_name
+----
+
+This string should be used in the application.properties file.
+
+=== How to run the producer
+
+Then you can run this producer example using:
+
+[source,sh]
+----
+$ jbang -Dcamel.jbang.version=4.5.0-SNAPSHOT camel run
timer-to-azure-servicebus.yaml
+----
+
+=== How to run the consumer
+
+Then you can run this consumer example using:
+
+[source,sh]
+----
+$ jbang -Dcamel.jbang.version=4.5.0-SNAPSHOT camel run
azure-servicebus-to-log.yaml
+----
+
+
diff --git a/jbang/azure-servicebus/application.properties
b/jbang/azure-servicebus/application.properties
new file mode 100644
index 0000000..c0a573c
--- /dev/null
+++ b/jbang/azure-servicebus/application.properties
@@ -0,0 +1 @@
+connectionString=RAW(<application.properties>)
diff --git a/jbang/azure-servicebus/azure-servicebus-to-log.yaml
b/jbang/azure-servicebus/azure-servicebus-to-log.yaml
new file mode 100644
index 0000000..f7e1b60
--- /dev/null
+++ b/jbang/azure-servicebus/azure-servicebus-to-log.yaml
@@ -0,0 +1,31 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+- route:
+ from:
+ uri: "kamelet:azure-servicebus-source"
+ parameters:
+ topicOrQueueName: "test"
+ connectionString: "{{connectionString}}"
+ steps:
+ - to:
+ uri: "kamelet:log-sink"
+ parameters:
+ showStreams: "true"
+ showHeaders: "true"
+ showBody: "true"
+
diff --git a/jbang/azure-servicebus/terraform/main.tf
b/jbang/azure-servicebus/terraform/main.tf
new file mode 100644
index 0000000..709bbcf
--- /dev/null
+++ b/jbang/azure-servicebus/terraform/main.tf
@@ -0,0 +1,29 @@
+provider "azurerm" {
+ features {}
+}
+
+# Creates the namespace
+resource "azurerm_servicebus_namespace" "busNamespace" {
+ name = var.services_bus_namespace_name
+ location = var.location
+ resource_group_name = var.resource_group_name
+ sku = "Basic"
+}
+
+# Create Queue for regular messages
+resource "azurerm_servicebus_queue" "messageQueue" {
+ name = var.messages_queue_name
+ namespace_id = azurerm_servicebus_namespace.busNamespace.id
+
+ enable_partitioning = true
+}
+
+# get Data for this queue
+resource "azurerm_servicebus_queue_authorization_rule" "messageQueueData" {
+ name = "messageQueue_auth_rule"
+ queue_id = azurerm_servicebus_queue.messageQueue.id
+
+ listen = true
+ send = true
+ manage = true
+}
diff --git a/jbang/azure-servicebus/terraform/outputs.tf
b/jbang/azure-servicebus/terraform/outputs.tf
new file mode 100644
index 0000000..5806791
--- /dev/null
+++ b/jbang/azure-servicebus/terraform/outputs.tf
@@ -0,0 +1,4 @@
+output messages_queue_name {
+ value =
azurerm_servicebus_queue_authorization_rule.messageQueueData.primary_connection_string
+ sensitive = true
+}
diff --git a/jbang/azure-servicebus/terraform/variables.tf
b/jbang/azure-servicebus/terraform/variables.tf
new file mode 100644
index 0000000..2ab0d94
--- /dev/null
+++ b/jbang/azure-servicebus/terraform/variables.tf
@@ -0,0 +1,5 @@
+variable location {}
+variable resource_group_name {}
+
+variable services_bus_namespace_name {}
+variable messages_queue_name {}
diff --git a/jbang/azure-servicebus/timer-to-azure-servicebus.yaml
b/jbang/azure-servicebus/timer-to-azure-servicebus.yaml
new file mode 100644
index 0000000..6004699
--- /dev/null
+++ b/jbang/azure-servicebus/timer-to-azure-servicebus.yaml
@@ -0,0 +1,30 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+- route:
+ from:
+ uri: "kamelet:timer-source"
+ parameters:
+ message: '{"id":"1","message":"Camel Rocks"}'
+ contentType: "application/json"
+ repeatCount: 10
+ steps:
+ - to:
+ uri: "kamelet:azure-servicebus-sink"
+ parameters:
+ topicOrQueueName: "test"
+ connectionString: "{{connectionString}}"