Updated on 2026-01-09 GMT+08:00

Creating an Event Function

Introduction

A function is customized code for processing events. You can create a function from scratch and configure the function based on site requirements.

FunctionGraph manages the compute resources required for function execution. After editing code for your function, configure compute resources on the FunctionGraph console.

You can create a function using a blank template, using other templates (by referring to Creating a Function Using a Template), or based on an image (by referring to Deploying a Function Using a Container Image).

When creating a function from scratch, configure the basic and code information based on Table 1. The parameters marked with an asterisk (*) are mandatory.

Each FunctionGraph function runs in its own environment and has its own resources and file system.

Prerequisites

  1. You must be familiar with the programming languages supported by FunctionGraph. For details, see Programming Models.
  2. Create a package. For details, see Creating a Deployment Package.
  3. (Optional) You have created an agency. For details, see Creating an Agency.

Procedure

  1. Log in to the FunctionGraph console. In the navigation pane, choose Functions > Function List.
  2. On the Function List page, click Create Function in the upper right corner.
  3. Click Create from scratch and configure the function information by referring to Table 1. The parameters marked with an asterisk (*) are mandatory.
    Table 1 Basic information

    Parameter

    Description

    *Function Type

    • Event Function: triggered by triggers.
    • HTTP Function: triggered once HTTP requests are sent to specific URLs.
      NOTE:
      • HTTP functions do not distinguish between programming languages. The handler must be set in the bootstrap file. You can directly write the startup command, and allow access over port 8000.
      • HTTP functions support APIG and APIC triggers only.
      • For details about how to use HTTP functions, see Creating an HTTP Function.

    *Region

    Select a region where you will deploy your code.

    *Function Name

    Name of the function, which must meet the following requirements:

    • Consists of 1 to 60 characters, and can contain letters, digits, hyphens (-), and underscores (_).
    • Starts with a letter and ends with a letter or digit.

    Agency

    An agency is required if FunctionGraph accesses other cloud services. For details on how to create an agency, see Creating an Agency.

    No agency is required if FunctionGraph does not access any cloud services.

    *Enterprise Project

    Select a created enterprise project and add the function to it. By default, default is selected.

    Runtime

    Select a runtime to compile the function.

  4. Click Create Function. On the displayed Code tab page, continue to configure the code.

Configuring Code

  1. You can deploy the code based on the runtime you select. For details, see Creating a Deployment Package. After the deployment is complete, click Deploy.

    As shown in the following example, to deploy code in Node.js 10.16, you can edit code inline, upload a local ZIP file, or upload a ZIP file from OBS.

  2. You can modify the code and click Deploy to deploy the code again.

Viewing Code Information

  1. View code attributes.

    Code attributes show the code size and the time the code was modified.

  2. View basic information.

    After a function is created, the default memory and execution timeout in each runtime are displayed. You can click Edit to switch to the Basic Settings page and modify Handler, Memory (MB), and Execution Timeout (s) as required.

    Once a function is created, the runtime cannot be changed.