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).
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:
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.
Past shows
- 2020/05/26 Using Docker Images with IBM Cloud Functions
- 2020/05/19 Intro to IBM Cloud Functions
- 2020/05/12 Aligning Audio Files
- 2020/05/05 Finding Similar Images with an Autoencoder
- 2020/04/30 Creating an Autoencoder in Python with Keras
- 2020/04/15 Scraping web content from graphql with Python
- 2020/04/07 Intro to Watson Data Studio and Investigating Air Quaility Data
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:
Top comments (0)