Workflow as a Function (WaaF)

workflow as function

Workflow as a Function is dedicated for short lived operations that usually last no longer that a second. They are expected to be fast and small in size both at runtime and at boot time.

Workflow as a Function typically targets deployments in more constrained environments such as:

however are not strictly limited to them, as they can easily be invoked over HTTP with both POST and GET endpoints, making them deployable virtually anywhere.

Functions can map data from payloads (POST) as well as from query parameters (GET).

Regardless of the number of activities it contains, the workflow is always exposed as a single function with its id being its public identifier, namely the function name.

Get started

To get started with Workflow as a Function users can take advantage of ready to use maven archetype to generate the project structure

  • automatiko-function-archetype - Tailored project type for workflow as a function use case

Here is a ready to use command to generate project based on automatiko-function-archetype

mvn archetype:generate                                      \
  -DarchetypeGroupId=io.automatiko.archetypes               \
  -DarchetypeArtifactId=automatiko-function-archetype       \
  -DarchetypeVersion=LATEST                                 \
  -DgroupId=com.acme.workflows                              \
  -DartifactId=workfow-function

Generated project has three maven profile defined that represents the target environment to deploy your function

  • azure - for Azure Functions

  • gcp - for Google Cloud Functions

  • lambda - for Amazon Lambda

Configure project

Once the project is bootstrapped, it needs to be configured according to the needs. There are two places where configuration is done

  • pom.xml - definition of the dependencies and Automatiko addons to be used

  • application.properties - all configuration parameters are defined there (found in src/main/resources directory)

A complete configuration of Automatiko specific configuration parameters can be found here, Quarkus specific configuration parameters can be found here.

Azure functions

Azure configuration uses azure-functions-maven-plugin and thus requires additional configuration to be set. Either by editing pom.xml file or using -D on the command lines. Here are the properties that must be set

  • functionResourceGroup - resource group in your Azure subscription to be used

  • functionAppPlan - application plan to be used

Once this is done Azure function deployment can be done via maven plugin

mvn clean package azure-functions:deploy -Pazure

This command will give you as output a HTTP Trigger Urls that points to your function.

Google Cloud functions

For Google Cloud functions it should be build with gcp profile

mvn clean package -Pgcp

And then deployed to your Google Cloud project using gcloud

gcloud functions deploy automatiko-user-registration-example \
  --entry-point=io.quarkus.gcp.functions.http.QuarkusHttpFunction \
  --runtime=java11 --trigger-http --source=target/deployment

This command will give you as output a httpsTrigger.url that points to your function.

Examples

Following is a list of examples that can be tried out to see Workflow as a Function in action

Table 1. Function examples
Name Description Link

user registration

BPMN based workflow for user registration that uses Swagger PetStore as user repository. Ready to be deployed to Azure Functions, Google Cloud Functions and Amazon Lambda

link