How-tos

New Alarm based trigger events for IBM Cloud Functions

Share this post:

IBM Cloud Functions offers great flexibility when it comes to using events to invoke your Actions.

Scheduled events are cloud native events you can programmatically control when they need to fire to run your serverless apps, instead of allocating an idle server just to schedule a job, you can use IBM Cloud Functions to orchestrate your applications using these type of triggers.

We recently enhanced the Alarm-based triggers, which fire a trigger at a specified frequency.
There are now 3 types of alarms that you can take advantage of to schedule the invocations of your Actions: interval based triggers, fire-once based triggers, and CRON based triggers.

Interval-based triggers

We heard from developers that they want to schedule their actions based on a simple interval. This can be useful in Continuous Deployment and Operations such as monitoring and health tests.
With the Interval based trigger from the alarms package, you can configure an action to run every set amount of minutes.

Here is an example of creating a trigger that fires an event every 42 minutes using the CLI:

bx wsk trigger create intervalTrigger --feed /whisk.system/alarms/interval -p minutes 42

Then you can use your trigger to create a rule:

bx wsk rule create intervalRule intervalTrigger monitorAction

You can learn more about firing a trigger event periodically on an interval-based schedule, including options such as start and stop parameters, in the Cloud Functions documentation.

Fire-once based triggers

In some cases, actions are meant to run once. These actions are usually created programmatically from your serverless apps to continue with a task or invoke a final Action at some point in the future. Or perhaps you just want to send a personalized social message to every family members at exactly midnight on New Year’s Eve!

Here is an example of creating a trigger that fires at New Year’s Eve using the CLI:

bx wsk trigger create onceTrigger --feed /whisk.system/alarms/once -p date "2019-01-01T00:00:00-05:00"

Then you can use your trigger to create a rule:

bx wsk rule create onceRule onceTrigger sendMessageAction

You can learn more about firing a trigger once on a specific date, including options to delete the trigger and the rule afterward, in the Cloud Functions documentation.

CRON-based triggers

The CRON-based trigger event was the first trigger available when we first introduced the periodic event-based Actions. We heard from developers that they want more control on when the trigger starts to fire and when it stops. This type of trigger was recently enhanced with two new options to handle start and stop dates.
You can learn more about how to use these two new options in the Cloud Functions documentation.

Note: These enhancements are available only via the Cloud Functions CLI plug-in. This blog post will be updated when the ability to create these triggers via the Cloud Functions UI is available.

Senior Technical Staff Member (STSM) - IBM Cloud Functions

More How-tos stories
August 13, 2018

CI/CD Pipeline for OpenWhisk Functions Using Whisk Deploy

The article presents a technique for developing a CI/CD pipeline in IBM Cloud for OpenWhisk functions using Whisk Deploy configuration cataloged in GitHub.

Continue reading

August 8, 2018

Creating A Microservice Data Lake With IBM Cloud Object Storage and IBM SQL Query

Is your application's data a stream trickling into a puddle or a rising tide overwhelming the levees? Either way, IBM has you covered with tools to store, retrieve, query, and gain insights from data of any size.

Continue reading

August 2, 2018

Connecting to IBM Cloud Object Store in Kubernetes

Operationalizing IBM SQL Query: Part 2. In this article, we'll take a look at the best practices for connecting to IBM Cloud Object Storage from docker containers deployed in the IBM Cloud Kubernetes Service.

Continue reading