loading...
Play Button Pause Button

Intro to IBM Cloud Functions

hammertoe profile image Matt Hamilton ・2 min read

IBM Cloud Functions are a "serverless" technology based on Apache Openwhisk hosted by IBM. They allow you to write code and deploy it without having to worry about hosting, operating systems.

Above is the first part of a series of live coding sessions on Twitch I've done exploring IBM Cloud functions and showing some simple examples.

Also available on Cinnamon at: https://www.cinnamon.video/watch?v=329436575563777372

Session recap

To start with you need an account on IBM Cloud. You can get a free account by signing up here.

You can either manage the Cloud functions through the IBM Cloud web portal, or you can use the command line interface (CLI). To install the CLI and Cloud Functions plugin, details are here: https://cloud.ibm.com/functions/learn/cli

There are four main constructs in Cloud Functions:

  • Actions
  • Sequences
  • Triggers -Rules

In this session, we mainly covered actions, which is where the code lives. IBM Cloud Functions is based on Apache Openwhisk and offers a number of different runtimes: JS/NodeJS, Swift, Java, Python, Ruby, Go, PHP, .NET, Any language (Docker).

Openwhisk runtimes

Some simple examples of creating, updating, invoking and deleting an action in IBM Cloud Functions

A simple hello world function:

def main(args):
    name = args.get("name", "unknown")
    return {"message": f"Hello {name}!"}

Create an action:

% ic fn action create hello hello.py
ok: created action hello

List actions:

% ic fn action list                             
actions
/Matthew.Hamilton1@ibm.com_dev/hello                                   private python:3.7

Invoke a function:

% ic fn action invoke hello -r
{
    "message": "Hello unknown!"
}

Update a function:

% ic fn action update hello hello.py
ok: updated action hello

Delete a function:

% ic fn action delete hello         
ok: deleted action hello

As usual all the code and examples here can be found in my Github repository for the show:

GitHub logo IBMDeveloperUK / ML-For-Everyone

Resources, notebooks, assets for ML for Everyone Twitch stream

ML for Everyone

ML For everyone is a live show broadcast on the IBM Developer Twitch channel every week at 2pm UK time.

The show is presented by Matt Hamilton and focusses on topics in and around machine learning for developers, with the odd smattering of random Python topics now and then.

Preview of show

Past shows

I hope you enjoyed the video, if you want to catch them live, I stream each week at 2pm UK time on the IBM Developer Twitch channel:

https://developer.ibm.com/livestream/

Posted on by:

hammertoe profile

Matt Hamilton

@hammertoe

Software developer. Developer Advocate at @IBMDeveloper. Tinkerer of motorbikes, vans, Arduinos, etc.

Discussion

pic
Editor guide