Developing a Cloud Function
In this tutorial we’ll create a new Cloud Function and test it in isolation. A basic understanding of Python is assumed.
What you need
- Linux, macOS or Windows with WSL2 (if you haven't done so yet, follow the steps in Prerequisites for development on Microsoft Windows Systems;
- Python 3.10 – can be downloaded from https://www.python.org/;
Please note:
If you are using WSL on Windows, make sure to install Python 3.10 or higher on the WSL. You can find out how to do so in the Installing Python3 in WSL section.
- Docker – can be downloaded from https://www.docker.com/;
- Code editor – it is recommended to use one that understands Python, such as Microsoft Visual Studio Code or JetBrains PyCharm Community.
Getting started
We’ll start by setting up a development environment for your new project.
Do not edit the Makefile!
Please do not make any changes to the Makefile as it is not intended to be changed.
- Download the workspace from Github as a ZIP file and extract it;
- Navigate to the
backend-component-workspace
directory; - Create the file
.accesstoken
and add an access token (when building separately from a UI Component):- Create the token by following Request a bearer token;
- Copy the file from your UI Component project after running
npx cdk login
.
- Run the command
make run
:
$ make run
Note for Windows Users:
If you are a Windows user, make sure to run any "make" commands in the WSL terminal opened on VS Code (or other editors).
- Open your browser and go to the http://127.0.0.1:8020/ page. It should look like the image below.
- Python names its functions based on the file path, file name and function name, separated by a full stop (.). Enter
functions.example.greet
in theFunction
field and click theRun function
button, located beforeFunction output
.
Sadly, it will return an error message, because we haven’t created the function yet!

Your first function
Let’s test out a function that lets us greet either a person or someone else specifically, if we want.
It is mandatory to add the @FunctionContext.expose
decorator to functions that you want to use in IXON Cloud.
- In the
functions
directory, you will find a file calledexample.py
. Open it in your editor; - This is what you will see:
from ixoncdkingress.function.context import FunctionContext
@FunctionContext.expose
def greet(context: FunctionContext, name: str = 'person'):
"""
A simple example function that greets someone.
"""
del context
return f'Greetings {name}!'
- Restart the test environment by running
make run
again; - Go back to http://127.0.0.1:8020/;
- Enter
functions.example.greet
in theFunctions
field and clickRun function
.
You should see the following result:
"Greetings person!"
Change the function
Now let’s try to greet someone else.
- In the first row of the table below
Function input
entername
underKey
andDeveloper
underValue
:
-
Run the function again and take a look at the output:
It now says Greetings Developer!
instead, fantastic! We now have all the ingredients for a Cloud Function.
Things to try out from here
Try saying Hello
to others. See what happens if you change the Key
to a different value, and how you can make the Cloud Function work with that other value.
Updated 10 days ago