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
April 30, 2019

Introducing IBM Analytics Engine v1.2 and Announcing the Deprecation of IBM Analytics Engine v1.0

We are excited to inform you about the new version of IBM Analytics Engine v1.2 that will be available starting May 15, 2019. Along with this release, Analytics Engine v1.0 will be retired.

Continue reading

April 23, 2019

Announcing the Deprecation of the Watson Machine Learning JSON Token Authentication Service

We’d like to inform you about the deprecation of the Watson Machine Learning JSON Token Authentication service. This method of authentication will be retired on May 30, 2019.

Continue reading

April 9, 2019

IBM Cloud Continuous Delivery is Now Better with Unlimited Insights

Starting this month, we are bundling IBM Continuous Delivery and IBM DevOps Insights to make the build, test, deploy, and learn experience on IBM Cloud even better.

Continue reading