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

How to deliver great performance for global apps on IBM Cloud

A large telecommunications service provider in Europe wants to serve customers in Brazil from their Frankfurt, Germany location. One challenge with such large geographical distances is achieving consistently low latency in order to provide a good user experience. Another challenge is scaling the infrastructure to handle a large number of user requests during peak traffic conditions.

Continue reading

Securing your Python app with OpenID Connect (OIDC)

Some weeks back I introduced to a tutorial on how to analyse GitHub traffic. The tutorial combines serverless technology and Cloud Foundry to automatically retrieve statistics and store them in Db2. The data can then be accessed and analyzed using a Python Flask app. Today, I am going to show you how the web site is protected using OpenID Connect and IBM Cloud App ID.

Continue reading

Custom login page for App ID integration

When developing an application that integrates with App ID, the standard hosted login page has a few options to change the colours or logo. In some cases, this isn't enough and direct customisation is necessary. There exists a handy guide for a custom App ID login screen in mobile applications, however for web applications a little more effort is required.

Continue reading