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 4ce403f Adding an example of context reloading with Azure Key Vault 4ce403f is described below commit 4ce403f128a9a274981d1c4f2cdf7c6437236637 Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Thu Sep 22 11:40:27 2022 +0200 Adding an example of context reloading with Azure Key Vault Signed-off-by: Andrea Cosentino <anco...@gmail.com> --- .../azure-key-vault-secrets-reloading/README.adoc | 132 +++++++++++++++++++++ .../azure-sec-integration.properties | 13 ++ .../timer-azure-key-vault-reloading.yaml | 32 +++++ 3 files changed, 177 insertions(+) diff --git a/jbang/azure-key-vault-secrets-reloading/README.adoc b/jbang/azure-key-vault-secrets-reloading/README.adoc new file mode 100644 index 0000000..e779969 --- /dev/null +++ b/jbang/azure-key-vault-secrets-reloading/README.adoc @@ -0,0 +1,132 @@ +== Azure Key Vault Example + +In this sample you'll use the Azure Key Vault Properties Source + +=== 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. + +=== Setup the Azure Key Vault service + +You'll need to have a key vault as first step. + +Then you'll need to create an event grid subscription to Eventhubs with a Blob Account and container for storing the checkpoint. + +It's not totally easy to do through the az cli, but everything could be done through the Azure UI. We're planning to improve this example by having all the instructions exposed as Azure CLI commands. + +Set all the credentials in the application.properties file correctly + +Create a secret on Azure + +[source,sh] +---- +az keyvault secret set --name hello --vault-name <vault_name> --value 'Camel Rocks!' +---- + +=== Setting up the Azure Key Vault credentials + +You should have a file like this in the end: + +[source,sh] +---- +camel.vault.azure.tenantId = <tenant_id> +camel.vault.azure.clientId = <client_id> +camel.vault.azure.clientSecret = <client_secret> +camel.vault.azure.vaultName = <vault_name> +camel.vault.azure.refreshEnabled=true +camel.vault.azure.refreshPeriod=15000 +camel.vault.azure.secrets=hello* +camel.vault.azure.eventhubConnectionString=<eventhub_conn_string> +camel.vault.azure.blobAccountName=<blob_account_name> +camel.vault.azure.blobContainerName=<blob_container_name> +camel.vault.azure.blobAccessKey=<blob_access_key> +camel.main.context-reload-enabled = true +---- + +=== How to run + +Then you can run this example using: + +[source,sh] +---- +$ camel run --properties=azure-sec-integration.properties timer-azure-key-vault-reloading.yaml +---- + +Or run it even shorter: + +[source,sh] +---- +$ camel run * +---- + +Or run with JBang using the longer command line (without installing camel as app in JBang): + +[source,sh] +---- +$ jbang camel@apache/camel run --properties=azure-sec-integration.properties timer-azure-key-vault-reloading.yaml +---- + +=== Modify the secret + +You can list the secrets in use from the Azure security vault: + +[source,sh] +---- +camel get vault +---- + +While the integration is running you could modify the secret and the integration will reload automatically + +[source,sh] +---- +az keyvault secret set --name hello --vault-name <vault_name> --value 'Camel Rocks reloaded!' +---- + +Now, get back, to the running Camel application and wait for the reloading. + +And the secret should also now be listed as updated form the get vault command: + +[source,sh] +---- +camel get vault +---- + +=== Developer Web Console + +You can enable the developer console via `--console` flag as show: + +[source,sh] +---- +$ camel run --properties=azure-sec-integration.properties timer-azure-key-vault-reloading.yaml --console +---- + +Then you can browse: http://localhost:8080/q/dev to introspect the running Camel applicaton. + + +=== Help and contributions + +If you hit any problem using Camel or have some feedback, then please +https://camel.apache.org/community/support/[let us know]. + +We also love contributors, so +https://camel.apache.org/community/contributing/[get involved] :-) + +The Camel riders! diff --git a/jbang/azure-key-vault-secrets-reloading/azure-sec-integration.properties b/jbang/azure-key-vault-secrets-reloading/azure-sec-integration.properties new file mode 100644 index 0000000..871398a --- /dev/null +++ b/jbang/azure-key-vault-secrets-reloading/azure-sec-integration.properties @@ -0,0 +1,13 @@ +camel.vault.azure.tenantId = <tenant_id> +camel.vault.azure.clientId = <client_id> +camel.vault.azure.clientSecret = <client_secret> +camel.vault.azure.vaultName = <vault_name> +camel.vault.azure.refreshEnabled=true +camel.vault.azure.refreshPeriod=15000 +camel.vault.azure.secrets=hello* +camel.vault.azure.eventhubConnectionString=<eventhub_conn_string> +camel.vault.azure.blobAccountName=<blob_account_name> +camel.vault.azure.blobContainerName=<blob_container_name> +camel.vault.azure.blobAccessKey=<blob_access_key> +camel.main.context-reload-enabled = true +camel.main.name = AzureExample diff --git a/jbang/azure-key-vault-secrets-reloading/timer-azure-key-vault-reloading.yaml b/jbang/azure-key-vault-secrets-reloading/timer-azure-key-vault-reloading.yaml new file mode 100644 index 0000000..7b93ef1 --- /dev/null +++ b/jbang/azure-key-vault-secrets-reloading/timer-azure-key-vault-reloading.yaml @@ -0,0 +1,32 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# camel-k: dependency=camel:azure-key-vault + +- route: + from: + uri: "kamelet:timer-source" + parameters: + period: 10000 + message: 'test' + steps: + - set-body: + simple: "Secret is {{azure:hello}}" + - to: + uri: "kamelet:log-sink" + parameters: + showStreams: true