Integrating the IBM Cloud Functions Periodic Triggers and Actions to schedule the VSI power on and power off.

We previously announced the suspend billing capabilities for Virtual Server Infrastructure (VSI) that are helping customer to pay only for what they use. In addition to this, we can integrate the IBM Cloud Functions Periodic Triggers and Actions to schedule the VSI power on and power off. 

NOTE: For VPC/Code Engine deployments, see “Using IBM Cloud Code Engine to Turn Virtual Server Instances On/Off in an Automated/Scheduled Manner.”


Creating the Functions Action

The following steps will help you to create an Action on the IBM Cloud Functions. This Action is based on a Python 2 script and can be used to both power the VSI on or power it off. 

  1. Clone this repo using the “git clone” command and access the app folder:
    git clone
    cd PowerOff-Functions
  2. Modify the file, replacing the <username> with the SoftLayer UserName and <apikey> with the API Key. To get the API keys for Softlayer, please visit Your Softlayer Profile under “API Access Information.”

    username = '<username>'
    key = '<apikey>'

    Figure 1: Inserting the username and API key on file.

  3. Create the Python virtualenv using a docker command (no need to modify, just copy and paste on the terminal.

    docker run --rm -v "$PWD:/tmp" openwhisk/python2action bash -c "cd /tmp && virtualenv virtualenv && source virtualenv/bin/activate && pip install -r requirements.txt"
  4. Create the zip file with virtualenv folder and file
    zip -r <zip_file> <virtualenv_folder> <main_file>


    zip -r virtualenv
  5. Push the zip “package” to IBM Cloud Functions:

    ibmcloud fn action create <action_name> <zip_file> --kind


    ibmcloud fn action create itiroaction01 --kind python:2

Creating the Functions Periodic Trigger

A trigger is a declaration that you want to react to a certain type of event, whether from a user or an event source. Triggers fire when they receive an event. In our case, we are using the Period events to fire the Trigger.

  1. Open the IBM Cloud console.
  2. Log in to the IBM Cloud Console using your credentials (username and password).
  3. Click on the three-line menu (hamburger menu) and click on Functions.
  4. Click on Actions and check if you Action appear on the list. In my example, I’m using “itiroaction01” for the action name.
  5. Click on Trigger and click on the Create button to create a new Function Trigger.
  6. Click on Create Trigger.
  7. Click on Periodic.

    Figure 2: Choosing the Periodic Trigger.

  8. Type the name in the Trigger Name field.

  9. Select the date, days, and hours that the action will be executed. You can select a predefined period in the Select pattern field:

    Figure 3: Configuring the New Trigger.

  10. In the JSON Payload field, type:




    OBS: Change <name_of_the_vsi> brackets with the name of the VSI that needs to be powered on/off.

  11. Click the Create button.

  12. On the next screen, click the Add button to associate an action with the Trigger.

  13. Click the Select Existing button:

    Figure 4: Selecting the Action.

  14. Click on the Select an Action field and select your action.

  15. Click the Add button.

  16. Your Function is now created with a Trigger and an Action to power on a VSI named “virtualserver01“.

You can now use the same example to create another Trigger to power off a VSI. To do that, just change the value of “poweraction” to “off” in Step 10.



More from Cloud

Kubernetes version 1.28 now available in IBM Cloud Kubernetes Service

2 min read - We are excited to announce the availability of Kubernetes version 1.28 for your clusters that are running in IBM Cloud Kubernetes Service. This is our 23rd release of Kubernetes. With our Kubernetes service, you can easily upgrade your clusters without the need for deep Kubernetes knowledge. When you deploy new clusters, the default Kubernetes version remains 1.27 (soon to be 1.28); you can also choose to immediately deploy version 1.28. Learn more about deploying clusters here. Kubernetes version 1.28 In…

Temenos brings innovative payments capabilities to IBM Cloud to help banks transform

3 min read - The payments ecosystem is at an inflection point for transformation, and we believe now is the time for change. As banks look to modernize their payments journeys, Temenos Payments Hub has become the first dedicated payments solution to deliver innovative payments capabilities on the IBM Cloud for Financial Services®—an industry-specific platform designed to accelerate financial institutions' digital transformations with security at the forefront. This is the latest initiative in our long history together helping clients transform. With the Temenos Payments…

Foundational models at the edge

7 min read - Foundational models (FMs) are marking the beginning of a new era in machine learning (ML) and artificial intelligence (AI), which is leading to faster development of AI that can be adapted to a wide range of downstream tasks and fine-tuned for an array of applications.  With the increasing importance of processing data where work is being performed, serving AI models at the enterprise edge enables near-real-time predictions, while abiding by data sovereignty and privacy requirements. By combining the IBM watsonx data…

The next wave of payments modernization: Minimizing complexity to elevate customer experience

3 min read - The payments ecosystem is at an inflection point for transformation, especially as we see the rise of disruptive digital entrants who are introducing new payment methods, such as cryptocurrency and central bank digital currencies (CDBC). With more choices for customers, capturing share of wallet is becoming more competitive for traditional banks. This is just one of many examples that show how the payments space has evolved. At the same time, we are increasingly seeing regulators more closely monitor the industry’s…