Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ readme's instructions.
=== Examples

// examples: START
Number of Examples: 72 (0 deprecated)
Number of Examples: 73 (0 deprecated)

[width="100%",cols="4,2,4",options="header"]
|===
Expand Down Expand Up @@ -81,6 +81,8 @@ Number of Examples: 72 (0 deprecated)

| link:azure/camel-example-spring-boot-azure-servicebus/README.adoc[Spring Boot Azure Servicebus] (camel-example-spring-boot-azure-servicebus) | Cloud | An example showing how to work with Camel, Azure Service Bus and Spring Boot

| link:azure/camel-example-spring-boot-azure-storage-blob/README.adoc[Spring Boot Azure Storage Blob] (camel-example-spring-boot-azure-storage-blob) | Cloud | An example showing how to work with Camel, Azure Storage Blob and Spring Boot

| link:infinispan/README.adoc[Infinispan] (infinispan) | Cloud | An example showing the Camel Infinispan component with Spring Boot

| link:webhook/readme.adoc[Webhook] (webhook) | Cloud | Example on how to use the Camel Webhook component
Expand Down
37 changes: 37 additions & 0 deletions azure/camel-example-spring-boot-azure-storage-blob/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
== Camel Azure Storage Blob Example

=== Introduction

This example demonstrates how to use the Apache Camel Azure Storage Blob component with Spring Boot to:

* Upload block blobs
* Set and get blob index tags
* Find blobs by tag filter expressions
* Create and read blob snapshots

=== Running Tests (Azurite)

Tests run automatically against https://github.com/Azure/Azurite[Azurite] (Azure Storage emulator) via Testcontainers. Docker must be running.

mvn verify

=== Running with Azure

To run against a real Azure Storage account:

1. Create a General-purpose v2 Storage Account in the Azure portal
2. Enable blob versioning under Data management > Data protection (optional, for version operations)
3. Get your account name and access key from Security + networking > Access keys

export AZURE_STORAGE_ACCOUNT_NAME=youraccount
export AZURE_STORAGE_ACCESS_KEY=yourkey
export AZURE_STORAGE_CONTAINER_NAME=yourcontainer
mvn spring-boot:run

=== Help and Contributions

If you hit any problems please let us know on the https://camel.apache.org/community/mailing-list/[Camel Forums].

Please help us make Apache Camel better - we appreciate any feedback you may have.

https://camel.apache.org/community/contributing/[Contributing]
102 changes: 102 additions & 0 deletions azure/camel-example-spring-boot-azure-storage-blob/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

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.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.camel.springboot.example</groupId>
<artifactId>camel-example-spring-boot-azure</artifactId>
<version>4.23.0-SNAPSHOT</version>
</parent>

<artifactId>camel-example-spring-boot-azure-storage-blob</artifactId>
<name>Camel SB Examples :: Azure Storage Blob</name>
<description>An example showing how to work with Camel, Azure Storage Blob and Spring Boot</description>

<properties>
<category>Cloud</category>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>

<!-- Camel -->
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-azure-storage-blob-starter</artifactId>
</dependency>

<!-- Test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-spring-junit6</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>${testcontainers-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-junit-jupiter</artifactId>
<version>${testcontainers-version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot-version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.
*/
package camel.sample;

import com.azure.storage.blob.BlobServiceClient;
import com.azure.storage.blob.BlobServiceClientBuilder;
import com.azure.storage.common.StorageSharedKeyCredential;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class BlobConfiguration {

@Value("${azure.storage.account-name}")
private String accountName;

@Value("${azure.storage.access-key}")
private String accessKey;

@Bean
BlobServiceClient serviceClient() {
String endpoint = String.format("https://%s.blob.core.windows.net", accountName);
return new BlobServiceClientBuilder()
.endpoint(endpoint)
.credential(new StorageSharedKeyCredential(accountName, accessKey))
.buildClient();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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.
*/
package camel.sample;

import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;

@Component
public class BlobRouteBuilder extends RouteBuilder {

@Override
public void configure() {
from("direct:uploadBlob")
.to("azure-storage-blob://{{azure.storage.account-name}}/{{azure.storage.container-name}}"
+ "?operation=uploadBlockBlob"
+ "&serviceClient=#serviceClient");
Comment thread
tdiesler marked this conversation as resolved.

from("direct:getBlob")
.to("azure-storage-blob://{{azure.storage.account-name}}/{{azure.storage.container-name}}"
+ "?operation=getBlob"
+ "&serviceClient=#serviceClient")
.convertBodyTo(byte[].class);
}
}
Original file line number Diff line number Diff line change
@@ -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.
*/
package camel.sample;

import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;

@Component
public class BlobSnapshotRouteBuilder extends RouteBuilder {

@Override
public void configure() {
from("direct:createSnapshot")
.to("azure-storage-blob://{{azure.storage.account-name}}/{{azure.storage.container-name}}"
+ "?operation=createBlobSnapshot"
+ "&serviceClient=#serviceClient");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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.
*/
package camel.sample;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class BlobStorageApplication {

public static void main(String[] args) {
SpringApplication.run(BlobStorageApplication.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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.
*/
package camel.sample;

import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;

@Component
public class BlobTagsRouteBuilder extends RouteBuilder {

@Override
public void configure() {
from("direct:setBlobTags")
.to("azure-storage-blob://{{azure.storage.account-name}}/{{azure.storage.container-name}}"
+ "?operation=setBlobTags"
+ "&serviceClient=#serviceClient");

from("direct:getBlobTags")
.to("azure-storage-blob://{{azure.storage.account-name}}/{{azure.storage.container-name}}"
+ "?operation=getBlobTags"
+ "&serviceClient=#serviceClient");

from("direct:findBlobsByTags")
.to("azure-storage-blob://{{azure.storage.account-name}}/{{azure.storage.container-name}}"
+ "?operation=findBlobsByTags"
+ "&serviceClient=#serviceClient");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# 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.
#

azure:
Comment thread
tdiesler marked this conversation as resolved.
storage:
account-name: ${AZURE_STORAGE_ACCOUNT_NAME:devstoreaccount1}
access-key: ${AZURE_STORAGE_ACCESS_KEY}
container-name: ${AZURE_STORAGE_CONTAINER_NAME:testcontainer}

camel:
component:
azure-storage-blob:
credential-type: SHARED_KEY_CREDENTIAL
Comment thread
tdiesler marked this conversation as resolved.
springboot:
main-run-controller: true
Loading
Loading