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:

[code language=”bash”]
bx wsk trigger create intervalTrigger –feed /whisk.system/alarms/interval -p minutes 42
[/code]

Then you can use your trigger to create a rule:

[code language=”bash”]
bx wsk rule create intervalRule intervalTrigger monitorAction
[/code]

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:

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

Then you can use your trigger to create a rule:

[code]
bx wsk rule create onceRule onceTrigger sendMessageAction
[/code]

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
October 19, 2018

Part 1: Build Messaging Solutions with Apache Kafka or Event Streams for IBM Cloud

As part of the iterative approach described in the main introduction blog of this series, the first step is to building messaging solutions is to identify the use case requirements and quantify these requirements as much as possible in terms of Apache Kafka and Event Streams.

Continue reading

October 18, 2018

Mount iSCSI Block Storage on VMware ESXi 6.5U2

It seems like pretty much everyone is using VMware ESXi virtualization nowadays. In this article, I'll cover how to mount IBM Cloud Block Storages onto this popular hypervisor using the iSCSI protocol.

Continue reading

October 18, 2018

Journey to Cloud – Moving On-Premise Mobile Foundation Apps to IBM Cloud

IBM MobileFirst Platform Foundation powers many on-premise customers in more than 50 countries, delivering the best-of-the-best apps and serving a large number of users. IBM Cloud Mobile Foundation Service offers all the same capabilities available in on-premise MobileFirst Foundation, with the additional benefits of fully managed service with instant deployment and scale-out option.

Continue reading