Kamelet Catalog

azure functions sink Azure Function Sink

Provided by: "Apache Software Foundation"

Support Level for this Kamelet is: "Stable"

Calls a function in Azure Functions over HTTP for each message, with the message as the body of the request.

Use it to run your own serverless code on each message, such as an enrichment, a notification or a calculation. For any other web service, use http-sink.

Input: the body is sent as the request body, as text, bytes or a stream. Turn structured data such as a Map into JSON text first, for example with json-serialize-action. The Content-Type header is sent as the content type of the request, and the other headers of the message, except the Camel ones, are sent as HTTP headers.

Output: when it is used inside a route, the body afterwards is the response of the function, and the CamelHttpResponseCode header its status code.

Good to know: a response with a status code outside 200 to 299 fails the message. The key is sent in the x-functions-key header, not in the address of the request, so error messages and access logs do not show it. The header is removed from the message after the call, also when the call fails. An x-functions-key, Authorization or Proxy-Authorization header on the incoming message is removed first, so a credential that came with the message is not sent on. Headers that start with CamelHttp or CamelRestHttp are removed from the message first, so they cannot change what the Kamelet does.

Configuration Options

The following table summarizes the configuration options available for the azure-functions-sink Kamelet:

Property Name Description Type Default Example

url

URL

Required The address of the function, which starts with https://, from the Azure portal: the function, then Get function URL. Leave out the ?code= part: put the key in key.

string

https://azure-function-demo-12234.azurewebsites.net/api/httpexample

key

Key

A function key, or the master key, from the Azure portal: the function, then Function Keys. Needed when the authorization level of the function is function or admin; leave it empty for anonymous. It is sent in the x-functions-key header.

string

method

Method

The HTTP method of the request, which must be one that the function accepts.

Enum values:

* GET * POST * PUT * DELETE * HEAD * OPTIONS * TRACE * PATCH

string

POST

Dependencies

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

  • camel:vertx-http

  • camel:kamelet

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:azure-functions-sink"

You can now run it directly through the following command

camel run route.yaml

Azure Functions Sink Kamelet Description

Authentication methods

In this Kamelet you should access the function on Azure through a key token in the key parameter.

The key is sent in the x-functions-key header, so the address of the request, which error messages and access logs show, does not hold it. The header is removed from the message after the call, also when the call fails:

- route:
    from:
      uri: "kamelet:timer-source"
      parameters:
        message: "hello"
      steps:
        - to:
            uri: "kamelet:azure-functions-sink"
            parameters:
              url: "https://azure-function-demo-12234.azurewebsites.net/api/httpexample"
              key: "{{function.key}}"