Camel Components

Azure Functions

Since Camel 4.19

Only producer is supported

The azure-functions component enables integration with Azure Functions. Azure Functions is a serverless compute service that enables you to run code on-demand without having to explicitly provision or manage infrastructure.

This component supports:

  • Invoking HTTP-triggered Azure Functions

  • Managing Azure Function Apps (list, create, delete, start, stop, restart)

  • Managing function app configuration and tags

Prerequisites

You must have a valid Azure subscription. More information is available at Azure Documentation Portal.

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-azure-functions</artifactId>
    <version>${camel-version}</version>
</dependency>

where ${camel-version} must be replaced by the actual version of Camel.

Configuring Options

Camel components are configured on two separate levels:

  • component level

  • endpoint level

Configuring Component Options

At the component level, you set general and shared configurations that are, then, inherited by the endpoints. It is the highest configuration level.

For example, a component may have security settings, credentials for authentication, urls for network connection and so forth.

Some components only have a few options, and others may have many. Because components typically have pre-configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.

You can configure components using:

  • the Component DSL.

  • in a configuration file (application.properties, *.yaml files, etc).

  • directly in the Java code.

Configuring Endpoint Options

You usually spend more time setting up endpoints because they have many options. These options help you customize what you want the endpoint to do. The options are also categorized into whether the endpoint is used as a consumer (from), as a producer (to), or both.

Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL and DataFormat DSL as a type safe way of configuring endpoints and data formats in Java.

A good practice when configuring options is to use Property Placeholders.

Property placeholders provide a few benefits:

  • They help prevent using hardcoded urls, port numbers, sensitive information, and other settings.

  • They allow externalizing the configuration from the code.

  • They help the code to become more flexible and reusable.

The following two sections list all the options, firstly for the component followed by the endpoint.

Component Options

The Azure Functions component supports the following options which are listed below.

Name Description Default Type

configuration (producer)

The component configuration.

FunctionsConfiguration

connectionTimeout (producer)

The timeout in milliseconds to connect to the function app for invokeFunction. Must be greater than 0.

30000

int

httpMethod (producer)

The HTTP method of the invokeFunction request, such as GET, POST, PUT or DELETE. GET and DELETE send no body.

POST

String

lazyStartProducer (producer)

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

location (producer)

The Azure region of the function app that createFunctionApp creates, such as eastus or westeurope. Required for createFunctionApp.

String

operation (producer)

The operation to perform. invokeFunction calls an HTTP-triggered function; the other operations manage the function app through Azure Resource Manager and need subscriptionId and resourceGroup. The CamelAzureFunctionsOperation header overrides it.

Enum values:

  • invokeFunction

  • listFunctionApps

  • getFunctionApp

  • createFunctionApp

  • deleteFunctionApp

  • startFunctionApp

  • stopFunctionApp

  • restartFunctionApp

  • listFunctions

  • getFunction

  • getFunctionKeys

  • getFunctionAppConfiguration

  • updateFunctionAppConfiguration

  • listTags

  • tagResource

  • untagResource

invokeFunction

FunctionsOperations

readTimeout (producer)

The timeout in milliseconds to wait for the response of the function for invokeFunction (the request timeout of the Java HTTP client): the exchange fails with an HttpTimeoutException when it elapses. Must be greater than 0.

60000

int

runtime (producer)

The language runtime of the function app that createFunctionApp creates: java, node, python or dotnet (case-insensitive), set as the FUNCTIONS_WORKER_RUNTIME app setting. Another value or no value sets no FUNCTIONS_WORKER_RUNTIME.

String

runtimeVersion (producer)

The runtime version of the function app that createFunctionApp creates. Not used yet: createFunctionApp always sets the Functions runtime version 4.

String

storageAccountConnectionString (producer)

The connection string of the storage account of the function app that createFunctionApp creates, set as the AzureWebJobsStorage app setting. Required for createFunctionApp.

String

throwExceptionOnFailure (producer)

Option to disable throwing the HttpOperationFailedException when the function answers invokeFunction with an HTTP status of 400 or above. This allows you to get all responses regardless of the HTTP status code, with the status in the CamelAzureFunctionsStatusCode header.

true

boolean

appServiceManager (advanced)

Autowired The AppServiceManager that the management operations use, instead of one that the component creates from the subscriptionId, tenantId and credential options.

AppServiceManager

autowiredEnabled (advanced)

Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.

true

boolean

clientId (security)

The client ID of the Microsoft Entra application (service principal) that the management operations authenticate with. Used only when clientId, clientSecret and tenantId are all set and credentialType is AZURE_IDENTITY or FUNCTION_KEY.

String

clientSecret (security)

The client secret of the Microsoft Entra application (service principal) that the management operations authenticate with. Used only when clientId, clientSecret and tenantId are all set and credentialType is AZURE_IDENTITY or FUNCTION_KEY.

String

credentialType (security)

How the management operations authenticate to Azure. AZURE_IDENTITY and FUNCTION_KEY use the client secret credential when clientId, clientSecret and tenantId are all set, else DefaultAzureCredential; TOKEN_CREDENTIAL uses the tokenCredential option. Not used when appServiceManager is set, nor by invokeFunction, which sends the functionKey or hostKey when one is set.

Enum values:

  • AZURE_IDENTITY

  • FUNCTION_KEY

  • TOKEN_CREDENTIAL

AZURE_IDENTITY

CredentialType

functionKey (security)

The function key that invokeFunction sends in the x-functions-key HTTP header. Takes precedence over hostKey. Not used by the management operations.

String

hostKey (security)

The host key of the function app that invokeFunction sends in the x-functions-key HTTP header when functionKey is not set. Not used by the management operations.

String

resourceGroup (security)

The name of the resource group of the function app, used by the management operations: listFunctionApps lists the function apps of this resource group. Required when the operation of the endpoint is a management operation (any operation other than invokeFunction).

String

subscriptionId (security)

The ID of the Azure subscription of the function app, used by the management operations. Required when the operation of the endpoint is a management operation (any operation other than invokeFunction).

String

tenantId (security)

The Microsoft Entra tenant ID of the management operations: used with clientId and clientSecret, and as the tenant of the Azure profile of the management client.

String

tokenCredential (security)

Autowired The TokenCredential that the management operations authenticate with when credentialType is TOKEN_CREDENTIAL.

TokenCredential

Endpoint Options

The Azure Functions endpoint is configured using URI syntax:

azure-functions:functionApp/functionName

With the following path and query parameters:

Path Parameters

Name Description Default Type

functionApp (producer)

Required The Azure Function App name.

String

functionName (producer)

The function within the function app. Required for the invokeFunction and getFunction operations.

String

Query Parameters

Name Description Default Type

connectionTimeout (producer)

The timeout in milliseconds to connect to the function app for invokeFunction. Must be greater than 0.

30000

int

httpMethod (producer)

The HTTP method of the invokeFunction request, such as GET, POST, PUT or DELETE. GET and DELETE send no body.

POST

String

location (producer)

The Azure region of the function app that createFunctionApp creates, such as eastus or westeurope. Required for createFunctionApp.

String

operation (producer)

The operation to perform. invokeFunction calls an HTTP-triggered function; the other operations manage the function app through Azure Resource Manager and need subscriptionId and resourceGroup. The CamelAzureFunctionsOperation header overrides it.

Enum values:

  • invokeFunction

  • listFunctionApps

  • getFunctionApp

  • createFunctionApp

  • deleteFunctionApp

  • startFunctionApp

  • stopFunctionApp

  • restartFunctionApp

  • listFunctions

  • getFunction

  • getFunctionKeys

  • getFunctionAppConfiguration

  • updateFunctionAppConfiguration

  • listTags

  • tagResource

  • untagResource

invokeFunction

FunctionsOperations

readTimeout (producer)

The timeout in milliseconds to wait for the response of the function for invokeFunction (the request timeout of the Java HTTP client): the exchange fails with an HttpTimeoutException when it elapses. Must be greater than 0.

60000

int

runtime (producer)

The language runtime of the function app that createFunctionApp creates: java, node, python or dotnet (case-insensitive), set as the FUNCTIONS_WORKER_RUNTIME app setting. Another value or no value sets no FUNCTIONS_WORKER_RUNTIME.

String

runtimeVersion (producer)

The runtime version of the function app that createFunctionApp creates. Not used yet: createFunctionApp always sets the Functions runtime version 4.

String

storageAccountConnectionString (producer)

The connection string of the storage account of the function app that createFunctionApp creates, set as the AzureWebJobsStorage app setting. Required for createFunctionApp.

String

throwExceptionOnFailure (producer)

Option to disable throwing the HttpOperationFailedException when the function answers invokeFunction with an HTTP status of 400 or above. This allows you to get all responses regardless of the HTTP status code, with the status in the CamelAzureFunctionsStatusCode header.

true

boolean

lazyStartProducer (producer (advanced))

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

appServiceManager (advanced)

Autowired The AppServiceManager that the management operations use, instead of one that the component creates from the subscriptionId, tenantId and credential options.

AppServiceManager

clientId (security)

The client ID of the Microsoft Entra application (service principal) that the management operations authenticate with. Used only when clientId, clientSecret and tenantId are all set and credentialType is AZURE_IDENTITY or FUNCTION_KEY.

String

clientSecret (security)

The client secret of the Microsoft Entra application (service principal) that the management operations authenticate with. Used only when clientId, clientSecret and tenantId are all set and credentialType is AZURE_IDENTITY or FUNCTION_KEY.

String

credentialType (security)

How the management operations authenticate to Azure. AZURE_IDENTITY and FUNCTION_KEY use the client secret credential when clientId, clientSecret and tenantId are all set, else DefaultAzureCredential; TOKEN_CREDENTIAL uses the tokenCredential option. Not used when appServiceManager is set, nor by invokeFunction, which sends the functionKey or hostKey when one is set.

Enum values:

  • AZURE_IDENTITY

  • FUNCTION_KEY

  • TOKEN_CREDENTIAL

AZURE_IDENTITY

CredentialType

functionKey (security)

The function key that invokeFunction sends in the x-functions-key HTTP header. Takes precedence over hostKey. Not used by the management operations.

String

hostKey (security)

The host key of the function app that invokeFunction sends in the x-functions-key HTTP header when functionKey is not set. Not used by the management operations.

String

resourceGroup (security)

The name of the resource group of the function app, used by the management operations: listFunctionApps lists the function apps of this resource group. Required when the operation of the endpoint is a management operation (any operation other than invokeFunction).

String

subscriptionId (security)

The ID of the Azure subscription of the function app, used by the management operations. Required when the operation of the endpoint is a management operation (any operation other than invokeFunction).

String

tenantId (security)

The Microsoft Entra tenant ID of the management operations: used with clientId and clientSecret, and as the tenant of the Azure profile of the management client.

String

tokenCredential (security)

Autowired The TokenCredential that the management operations authenticate with when credentialType is TOKEN_CREDENTIAL.

TokenCredential

Message Headers

The Azure Functions component supports the following message header(s), which is/are listed below:

Name Description Default Type

CamelAzureFunctionsOperation (producer)

Constant: OPERATION

The operation to perform. Overrides the operation in the endpoint.

Enum values:

  • invokeFunction

  • listFunctionApps

  • getFunctionApp

  • createFunctionApp

  • deleteFunctionApp

  • startFunctionApp

  • stopFunctionApp

  • restartFunctionApp

  • listFunctions

  • getFunction

  • getFunctionKeys

  • getFunctionAppConfiguration

  • updateFunctionAppConfiguration

  • listTags

  • tagResource

  • untagResource

FunctionsOperations

CamelAzureFunctionsFunctionApp (producer)

Constant: FUNCTION_APP

The name of the function app. Overrides the function app of the endpoint.

String

CamelAzureFunctionsFunctionName (producer)

Constant: FUNCTION_NAME

The function within the function app. Overrides the function name of the endpoint.

String

CamelAzureFunctionsResourceGroup (producer)

Constant: RESOURCE_GROUP

The name of the resource group of the function app. Overrides the resourceGroup option.

String

CamelAzureFunctionsHttpMethod (producer)

Constant: HTTP_METHOD

The HTTP method of the invokeFunction request. Overrides the httpMethod option.

String

CamelAzureFunctionsHttpHeaders (producer)

Constant: HTTP_HEADERS

The HTTP headers to send with the invokeFunction request, as a Map of header names to values.

Map

Content-Type (producer)

Constant: CONTENT_TYPE

The content type of the body that invokeFunction sends. Used when the request has a body and the CamelAzureFunctionsHttpHeaders map sets no Content-Type; when neither sets one, application/json is sent.

String

CamelAzureFunctionsStatusCode (producer)

Constant: STATUS_CODE

The HTTP status code of the response of invokeFunction.

Integer

CamelAzureFunctionsResponseHeaders (producer)

Constant: RESPONSE_HEADERS

The HTTP headers of the response of invokeFunction.

Map

CamelAzureFunctionsFunctionAppState (producer)

Constant: FUNCTION_APP_STATE

The state of the function app, such as Running or Stopped. Set by getFunctionApp, startFunctionApp, stopFunctionApp and restartFunctionApp.

String

CamelAzureFunctionsResourceId (producer)

Constant: RESOURCE_ID

The Azure resource ID of the function app. Set by getFunctionApp and createFunctionApp.

String

CamelAzureFunctionsDefaultHostname (producer)

Constant: DEFAULT_HOSTNAME

The default host name of the function app. Set by getFunctionApp and createFunctionApp.

String

CamelAzureFunctionsAppSettings (producer)

Constant: APP_SETTINGS

The app settings that updateFunctionAppConfiguration adds or changes, as a Map of names to values. Required for updateFunctionAppConfiguration.

Map

CamelAzureFunctionsResourceTags (producer)

Constant: RESOURCE_TAGS

The tags that tagResource adds to the function app or changes, as a Map of names to values. Required for tagResource.

Map

CamelAzureFunctionsTagKeys (producer)

Constant: TAG_KEYS

The names of the tags that untagResource removes from the function app. Required for untagResource.

List

CamelAzureFunctionsLocation (producer)

Constant: LOCATION

The Azure region of the function app that createFunctionApp creates. Overrides the location option.

String

CamelAzureFunctionsRuntime (producer)

Constant: RUNTIME

The language runtime of the function app that createFunctionApp creates. Overrides the runtime option.

String

CamelAzureFunctionsRuntimeVersion (producer)

Constant: RUNTIME_VERSION

The runtime version of the function app that createFunctionApp creates. Not used yet.

String

CamelAzureFunctionsStorageConnectionString (producer)

Constant: STORAGE_CONNECTION_STRING

The connection string of the storage account of the function app that createFunctionApp creates. Overrides the storageAccountConnectionString option.

String

Message Body

The message body at each side of the Azure Functions component: Consumer is the body of the messages the consumer creates, Consumer reply the bodies a consumer that answers its caller can reply with, Producer input the bodies the producer can send or write, and Producer output the body after the producer.

Side Body Description

Producer input

text, value, bytes, stream, file or null

The request body of invokeFunction, the default: text, a number or a boolean is sent as text (UTF-8), and bytes, a stream or a file as their content. A Map or a POJO is not marshalled: marshal it to JSON first, as a body that does not convert to bytes fails. The Content-Type is the one the CamelAzureFunctionsHttpHeaders header sets, else the Content-Type header of the message, else application/json. GET and DELETE send no body. The management operations do not use the body: they take their input from headers, such as the app settings and the tags.

  • With operation=listFunctionApps: any

  • With operation=getFunctionApp: any

  • With operation=createFunctionApp: any

  • With operation=deleteFunctionApp: any

  • With operation=startFunctionApp: any

  • With operation=stopFunctionApp: any

  • With operation=restartFunctionApp: any

  • With operation=listFunctions: any

  • With operation=getFunction: any

  • With operation=getFunctionKeys: any

  • With operation=getFunctionAppConfiguration: any

  • With operation=updateFunctionAppConfiguration: any

  • With operation=listTags: any

  • With operation=tagResource: any

  • With operation=untagResource: any

Producer output

text (java.lang.String)

The response body of the function as text for invokeFunction, the default, with the status in the CamelAzureFunctionsStatusCode header. A status of 400 or above fails the exchange with an HttpOperationFailedException, unless throwExceptionOnFailure=false, which keeps the response as text. A List of Maps that describe the function apps or the functions for the list operations, a Map for the get and create operations, the settings or the tags as a Map, and true for delete, start, stop and restart.

  • With operation=listFunctionApps: list (java.util.List<java.util.Map<String, Object>>)

  • With operation=getFunctionApp: map (java.util.Map<String, Object>)

  • With operation=createFunctionApp: map (java.util.Map<String, Object>)

  • With operation=deleteFunctionApp: value (java.lang.Boolean)

  • With operation=startFunctionApp: value (java.lang.Boolean)

  • With operation=stopFunctionApp: value (java.lang.Boolean)

  • With operation=restartFunctionApp: value (java.lang.Boolean)

  • With operation=listFunctions: list (java.util.List<java.util.Map<String, Object>>)

  • With operation=getFunction: map (java.util.Map<String, Object>)

  • With operation=getFunctionKeys: map (java.util.Map<String, Object>)

  • With operation=getFunctionAppConfiguration: map (java.util.Map<String, String>)

  • With operation=updateFunctionAppConfiguration: map (java.util.Map<String, String>)

  • With operation=listTags: map (java.util.Map<String, String>)

  • With operation=tagResource: map (java.util.Map<String, String>)

  • With operation=untagResource: map (java.util.Map<String, String>)

The bodies are the ones with the default options. A side that is not listed is not known, and tooling does not guess it. The carriers, the sides and the tools that use them are described in Message Body Types.

URI Format

azure-functions:functionApp[/functionName]

Where:

  • functionApp is the name of your Azure Function App

  • functionName is the name of the function within the app (required for invokeFunction operation)

The invokeFunction operation calls https://<functionApp>.azurewebsites.net/api/<functionName>. The function app, from the endpoint or the CamelAzureFunctionsFunctionApp header, must be an app name: letters, digits and hyphens, not starting or ending with a hyphen, at most 60 characters. The function name, from the endpoint or the CamelAzureFunctionsFunctionName header, is the path after /api/: one or more segments separated by /, so a function with a custom route, such as products/42, can be called. Characters that are not allowed in a URL path, such as a space, are encoded. A function name with ?, #, \, %, an empty segment, or a . or .. segment is rejected, and so is a function app that is not an app name: the exchange fails with an IllegalArgumentException.

Usage

Authentication Information

There are three different Credential Types: AZURE_IDENTITY, FUNCTION_KEY, and TOKEN_CREDENTIAL.

AZURE_IDENTITY (default):

This will use com.azure.identity.DefaultAzureCredentialBuilder().build() instance. This follows the Default Azure Credential Chain which tries multiple authentication methods:

  • Environment variables

  • Managed Identity

  • Azure CLI

  • Visual Studio Code

  • IntelliJ IDEA

See the documentation here about Azure AD authentication.

FUNCTION_KEY:

For invoking HTTP-triggered functions, you can use function keys or host keys:

  • Java

  • XML

  • YAML

from("direct:invoke")
    .to("azure-functions:myFunctionApp/myFunction?credentialType=FUNCTION_KEY&functionKey=your-function-key");
<route>
  <from uri="direct:invoke"/>
  <to uri="azure-functions:myFunctionApp/myFunction?credentialType=FUNCTION_KEY&amp;functionKey=your-function-key"/>
</route>
- route:
    from:
      uri: direct:invoke
      steps:
        - to:
            uri: azure-functions:myFunctionApp/myFunction
            parameters:
              credentialType: FUNCTION_KEY
              functionKey: your-function-key

TOKEN_CREDENTIAL:

Provide an implementation of com.azure.core.credential.TokenCredential into the Camel Registry:

  • Java

  • XML

  • YAML

from("direct:invoke")
    .to("azure-functions:myFunctionApp/myFunction?credentialType=TOKEN_CREDENTIAL&tokenCredential=#myCredential");
<route>
  <from uri="direct:invoke"/>
  <to uri="azure-functions:myFunctionApp/myFunction?credentialType=TOKEN_CREDENTIAL&amp;tokenCredential=#myCredential"/>
</route>
- route:
    from:
      uri: direct:invoke
      steps:
        - to:
            uri: azure-functions:myFunctionApp/myFunction
            parameters:
              credentialType: TOKEN_CREDENTIAL
              tokenCredential: "#myCredential"

Service Principal Authentication

For service principal authentication, provide the client credentials:

  • Java

  • XML

  • YAML

from("direct:manage")
    .to("azure-functions:myFunctionApp?operation=listFunctionApps&subscriptionId=your-subscription-id&resourceGroup=your-resource-group&clientId=your-client-id&clientSecret=your-client-secret&tenantId=your-tenant-id");
<route>
  <from uri="direct:manage"/>
  <to uri="azure-functions:myFunctionApp?operation=listFunctionApps&amp;subscriptionId=your-subscription-id&amp;resourceGroup=your-resource-group&amp;clientId=your-client-id&amp;clientSecret=your-client-secret&amp;tenantId=your-tenant-id"/>
</route>
- route:
    from:
      uri: direct:manage
      steps:
        - to:
            uri: azure-functions:myFunctionApp
            parameters:
              operation: listFunctionApps
              subscriptionId: your-subscription-id
              resourceGroup: your-resource-group
              clientId: your-client-id
              clientSecret: your-client-secret
              tenantId: your-tenant-id

Invoking a function

The invokeFunction operation sends the message body to the function: text, a number or a boolean is sent as text (UTF-8), and bytes, a stream or a file (also the file of a file consumer) as their content. A Map or a POJO is not marshalled: marshal it to JSON first, for example with marshal().json(), as a body that does not convert to bytes fails the exchange. GET and DELETE send no body.

A request with a body has the Content-Type that the CamelAzureFunctionsHttpHeaders header, a Map<String, String> of HTTP headers to send, sets. When that map sets none, the Content-Type header of the message is used, and when the message has none either, Content-Type: application/json. Text is always sent as UTF-8: the charset parameter of a Content-Type from the message, for example text/plain; charset=ISO-8859-1, is not used for the encoding.

The response body of the function becomes the message body, as text, with the HTTP status in the CamelAzureFunctionsStatusCode header and the HTTP headers of the response in the CamelAzureFunctionsResponseHeaders header. A status of 400 or above fails the exchange with an org.apache.camel.http.base.HttpOperationFailedException, as the HTTP components do: it holds the status, the response body and the response headers. The message body is then still the request body, as in camel-http, with the status in the CamelAzureFunctionsStatusCode header. Set throwExceptionOnFailure=false to get the response of every status as the message body instead.

Operations

The component supports the following operations:

Function Invocation

Operation Description

invokeFunction

Invokes an HTTP-triggered Azure Function (default operation)

Function App Management

Operation Description

listFunctionApps

List all function apps in the subscription or resource group

getFunctionApp

Get details of a specific function app

createFunctionApp

Create a new function app

deleteFunctionApp

Delete a function app

startFunctionApp

Start a stopped function app

stopFunctionApp

Stop a running function app

restartFunctionApp

Restart a function app

Function Operations

Operation Description

listFunctions

List all functions within a function app

getFunction

Get details of a specific function

getFunctionKeys

Get the master key for the function app

Configuration Operations

Operation Description

getFunctionAppConfiguration

Get app settings/configuration

updateFunctionAppConfiguration

Update app settings

Tag Operations

Operation Description

listTags

List tags on the function app resource

tagResource

Add tags to the function app

untagResource

Remove tags from the function app

Examples

Invoke a Function

  • Java

  • XML

  • YAML

from("direct:invoke")
    .setBody(constant("{\"name\": \"World\"}"))
    .to("azure-functions:myFunctionApp/HelloFunction?functionKey=your-key")
    .log("Response: ${body}");
<route>
  <from uri="direct:invoke"/>
  <setBody>
    <constant>{"name": "World"}</constant>
  </setBody>
  <to uri="azure-functions:myFunctionApp/HelloFunction?functionKey=your-key"/>
  <log message="Response: ${body}"/>
</route>
- route:
    from:
      uri: direct:invoke
      steps:
        - setBody:
            constant: '{"name": "World"}'
        - to:
            uri: azure-functions:myFunctionApp/HelloFunction
            parameters:
              functionKey: your-key
        - log:
            message: "Response: ${body}"

List Function Apps

  • Java

  • XML

  • YAML

from("direct:list")
    .to("azure-functions:myFunctionApp?operation=listFunctionApps&subscriptionId=xxx&resourceGroup=myResourceGroup")
    .log("Function Apps: ${body}");
<route>
  <from uri="direct:list"/>
  <to uri="azure-functions:myFunctionApp?operation=listFunctionApps&amp;subscriptionId=xxx&amp;resourceGroup=myResourceGroup"/>
  <log message="Function Apps: ${body}"/>
</route>
- route:
    from:
      uri: direct:list
      steps:
        - to:
            uri: azure-functions:myFunctionApp
            parameters:
              operation: listFunctionApps
              subscriptionId: xxx
              resourceGroup: myResourceGroup
        - log:
            message: "Function Apps: ${body}"

Stop a Function App

  • Java

  • XML

  • YAML

from("direct:stop")
    .to("azure-functions:myFunctionApp?operation=stopFunctionApp&subscriptionId=xxx&resourceGroup=myResourceGroup")
    .log("Function App stopped");
<route>
  <from uri="direct:stop"/>
  <to uri="azure-functions:myFunctionApp?operation=stopFunctionApp&amp;subscriptionId=xxx&amp;resourceGroup=myResourceGroup"/>
  <log message="Function App stopped"/>
</route>
- route:
    from:
      uri: direct:stop
      steps:
        - to:
            uri: azure-functions:myFunctionApp
            parameters:
              operation: stopFunctionApp
              subscriptionId: xxx
              resourceGroup: myResourceGroup
        - log:
            message: "Function App stopped"

Update Configuration

Java-only: requires Java Map.of() for app settings
from("direct:updateConfig")
    .setHeader("CamelAzureFunctionsAppSettings", constant(Map.of("MY_SETTING", "value")))
    .to("azure-functions:myFunctionApp?operation=updateFunctionAppConfiguration&subscriptionId=xxx&resourceGroup=myResourceGroup")
    .log("Configuration updated: ${body}");

Create a Function App

  • Java

  • XML

  • YAML

from("direct:create")
    .to("azure-functions:newFunctionApp?operation=createFunctionApp&subscriptionId=xxx&resourceGroup=myResourceGroup&location=eastus&runtime=java&storageAccountConnectionString=RAW(DefaultEndpointsProtocol=https;...)")
    .log("Created function app: ${header.CamelAzureFunctionsResourceId}");
<route>
  <from uri="direct:create"/>
  <to uri="azure-functions:newFunctionApp?operation=createFunctionApp&amp;subscriptionId=xxx&amp;resourceGroup=myResourceGroup&amp;location=eastus&amp;runtime=java&amp;storageAccountConnectionString=RAW(DefaultEndpointsProtocol=https;...)"/>
  <log message="Created function app: ${header.CamelAzureFunctionsResourceId}"/>
</route>
- route:
    from:
      uri: direct:create
      steps:
        - to:
            uri: azure-functions:newFunctionApp
            parameters:
              operation: createFunctionApp
              subscriptionId: xxx
              resourceGroup: myResourceGroup
              location: eastus
              runtime: java
              storageAccountConnectionString: "RAW(DefaultEndpointsProtocol=https;...)"
        - log:
            message: "Created function app: ${header.CamelAzureFunctionsResourceId}"