Run your code without servers by FunctionGraph

Cetin Ulusoy
Huawei Developers
Published in
3 min readMay 16, 2023

Introduction

In this session we will compress images by automatically trigger the python code with using FunctionGraph

What is FunctionGraph

❗ Run your code without provisioning or managing servers ❗

FunctionGraph hosts and computes event-driven functions in a serverless context while ensuring high availability, high scalability, and zero maintenance. All you need to do is write your code and set conditions. You pay only for what you use and you are not charged when your code is not running.

Supported Languages

Summary of Demo

Topology

In this demo we will Upload images to a specified Object Storage Service (OBS) bucket after then FunctionGraph triggered and Compress each uploaded image.

Step by Step

1-Create two different buckets on the OBS console.

2-Create a function with an OBS trigger.

3-Upload an image to one of the buckets.

4-The function is triggered to compress the image.

5-The function uploads the processed image to the other bucket

Creating OBS Buckets

We created first OBS Bucket (b-input). We will upload images here
We created second OBS Bucket (b-output). After function triggered, compressed images will be here

Creating an Agency

We need Agency. We will create here: Log in to the IAM Console
Click to Agencies
Create Agency and choose settings like here
Assign permission to Agent
Authorized

Creating a Function

Choose your settings for create Function. We chose Create from Scratch, because we will be using our own code

Upload your code

Upload your Code (bottom right corner)
The code we used in this demo. Also you can customize your code here

Add Dependencies

Select Dependency
List of selected Dependencies

Configuration

Configuration settings: We set the Execution timeout and Memory for this function
Environment Variables: We entry here our output OBS bucket variables

Create Trigger

Set Trigger preferences. We will be use ObjectCreated. So if we upload any object to OBS, function will be triggered

Final 🎉

  • We uploaded image to our OBS bucket (b-input)
  • As we set before our code triggered when we upload image
  • Compressed image uploaded automatically to OBS bucket (b-output)
We Uploaded 207 kb size of image
Output image size 62 kb

If you’re interested in getting hands-on experience with Huawei Cloud Services , you can register and explore KooLabs , Huawei’s online interactive and free learning platform , as well as Huawei Cloud Developer Forum , where you can connect with other developers and gain insights into Huawei’s Cloud computing solutions.

You can reach me from my Linkedin account for all your questions and requests.

References

--

--