Multiple functions can be created for the same service. These functions share the log resources and role information configured for the service, but are independent and do not affect each other. This topic describes how to create, configure, and delete a function.

Background information

Function Compute allows you to create, update, and delete a function by using the following methods:

Create a function

  1. Log on to the Function Compute console.
  2. In the top navigation bar, select your region.
  3. In the left-side navigation pane, click Service/Function.
  4. Click Create Function, select a function type, and then click Next.
    In this example, select Event Function to create an event function.creat_function
  5. In the Configure Function step, specify the required information and click Create.
    config_function
    Parameter Description Example
    Service Name
    • If you have created at least one service, select an existing service from the drop-down list.
    • If you have not created any services, enter a new service name. The system then automatically creates a service with the specified service name.
    service
    Bind Log If you enter a new service name to trigger the system to automatically create a service, you must select Bind Log.

    After you bind a log to the service, you can view execution logs of the function. These logs help you develop and debug your function.

    In this example, an existing service is selected, and therefore this parameter is not specified.
    Function Name Enter a name for your function. function
    Runtime Select a language, such as Python, Java, PHP, or Node.js. python3
    Instance Type Select an instance type for your function. Valid values:
    • Flexible Instance
    • Performance Instance
    For more information, see Instance specifications.
    Flexible Instance
    Function Handler Enter the name of the function handler. The value is in the format of [File name].[ Function name]. index.handler
    Memory Set the memory that is required to execute the function. The maximum value is 3,072 MB. Default value: 512 MB. 512 MB
    Timeout Set the timeout period. The maximum value is 600 seconds. Default value: 60 seconds.

    If the execution of the function does not complete before the specified timeout period expires, the function fails to be executed.

    60
    Single Instance Concurrency The number of requests that can be concurrently processed by a single Function Compute instance. The Python 3 runtime environment does not support this feature.
    On the Service/Function page, you can click the target service to view the function created for the service.create_function_result

Modify a function

  1. Log on to the Function Compute console.
  2. In the top navigation bar, select your region.
  3. In the left-side navigation pane, click Service/Function.
  4. Click the service to which the target function belongs.
  5. In the function list, find the target function, and click Configure in the Actions column.
    config_function
  6. Modify the corresponding parameters, and then click Submit.
    You can modify the following parameters in Function Compute: Function Handler, Runtime, Instance Type, Memory, Timeout, Single Instance Concurrency, Enable Initializer, Function Description, and Environment Variables.
    Note The value of the Instance Type parameter can be changed only from Flexible Instance to Performance Instance. If the value of this parameter for your function is Performance Instance, you cannot change it to Flexible Instance.

Delete a function

Before you delete a service, ensure that you have deleted all triggers from the service. For more information, see Trigger management.

  1. Log on to the Function Compute console.
  2. In the top navigation bar, select your region.
  3. In the left-side navigation pane, click Service/Function.
  4. Click the service to which the target function belongs.
  5. In the function list, find the target function, and click Delete in the Actions column.