A function is the unit for system scheduling and operation in Function Compute. A function belongs to a service. In the service, you can create multiple functions that share some identical settings, such as service authorization and log settings. These functions are independent from each other. This topic describes the properties and runtime environments of functions, and how to create, configure, and delete functions in the Function Compute console.
Prerequisites
Supported runtime environments
Runtime environment | Description | References |
---|---|---|
Node.js 6.x | Node.js 6.x | Node.js runtime environments |
Node.js 8.x | Node.js 8.x | |
Node.js 10.x | Node.js 10.x | |
Node.js 12.x | Node.js 12.x | |
Node.js 14.x | Node.js 14.x | |
Python 2.7 | Python 2.7 | Python runtime environments |
Python 3 | Python 3.6 | |
Python 3.9 | Python 3.9 | |
PHP 7.2 | PHP 7.2.7 | PHP runtime environment |
Java 11 | Java 11 | Java runtime environments |
Java 8 | Java 8 | |
.NET Core 2.1 | .NET Core 2.1 | .NET Core runtime environment |
Go 1.x | Go 1.8 or later | Runtime environment |
Custom Runtime | N/A | Custom Runtime |
Custom Container | N/A | Custom Container |
Create a function
Obtain the ARN of a function
Update a function
- Log on to the Function Compute console.
- In the left-side navigation pane, click Services and Functions.
- In the top navigation bar, select the region where the service resides.
- On the Services page, click the target service.
- On the Functions page, find the function that you want to manage and click Configure in the Actions column.
- On the Modify Function Settings page, modify the configuration items based on your
business requirements and click Save.
- Optional: Basic Settings
Configure the basic information of the function. You can modify only the Description, Instance Category, and Memory Capacity parameters.
Parameter Description Description Enter a description for the function. The description helps you identify the purpose of the function. Instance Category The instance category for the function. Valid values: - Elastic Instance
- Performance Instance
Memory Capacity The memory that is required to execute the function. - Select Input: Select the required memory from the drop-down list.
- Manual Input: Click Manually Enter Memory Size to customize the memory size of the function. The memory specifications are described
as follows:
- Elastic Instance: Valid values: [128, 3072]. Unit: MB.
- Performance Instances: Valid values: [4 to 32]. Unit: GB.
Note The memory value must be a multiple of 64 MB.
Notice When you modify the Instance Category parameter, take note of the following rules:- You can change the value from Elastic Instance to Performance Instance or from Performance Instance to Elastic Instance.
- When you change the value from Performance Instance to Elastic Instance, the instance specifications are downgraded. In this case, Function Compute detects the switchover risk and automatically downgrades the memory size.
- Optional:Environment Information
Configure the runtime environment and other key parameters of the function.
Parameter Description Runtime Environment Select a language, such as Python, Java, PHP, or Node.js. For more information about the runtime environments supported by Function Compute, see . Request Handler The function handler, which is in the format of [File name].[Function name]. Notice If you set Runtime Environment to Custom Runtime, you cannot set the function handler.Startup Command (public preview) This parameter is required only when you set Runtime Environment to Custom Runtime. Configure the startup command for the custom bootstrap
file. You must enter an absolute path. Example:/code/Bootstrap
. Configure a custom startup command and the related parametersStartup Parameters (public preview) This parameter is required only when you set Runtime Environment to Custom Runtime. Configure the list of parameters received by the custom bootstrap
file.Listener Port This parameter is required only when you set Runtime Environment to Custom Runtime. Set the value of this parameter to the port on which the custom HTTP server listens. For more information about how to configure the listening port of the HTTP server, see Configuration requirements on an HTTP server. Execution Timeout Period The timeout period for the execution of the function. The default value is 60 seconds. The maximum value is 86400 seconds. Note If the execution time of the function exceeds the specified timeout period, the function fails to be executed. If you want to specify a longer timeout period, submit a ticket.Instance Concurrency The number of requests that can be concurrently processed by a single instance. For more information, see Set the request concurrency in a single instance. Notice This parameter is invalid for the Python and PHP runtime environments. - Optional:Other configurations
Parameter Description References Lifecycle Function The lifecycle functions of the function, including the initializer function, PreFreeze function, and PreStop function. Function instance lifecycle Layers The name and version of an existing layer. Layers allow you to publish and deploy custom resources such as public libraries, runtime environments, and function extensions. Use layers in functions Environment Variables The environment variables in the runtime environment of the function. Environment variables DNS Configuration The custom domain name system (DNS) settings. Function Compute generates the resolv.conf file based on the DNS settings. Configure custom DNS settings for functions
- Optional: Basic Settings
Delete a function
- Log on to the Function Compute console.
- In the left-side navigation pane, click Services and Functions.
- In the top navigation bar, select the region where the service resides.
- On the Services page, click the target service.
- On the Functions page, find the function that you want to delete and choose in the Actions column.
- Delete the function.
- If no trigger is configured for the function or the triggers configured for the function
are deleted, click Delete in the message that appears.
- If triggers are configured for the function and the triggers are not deleted, select
I want to delete the preceding resources and the function in the dialog box that appears. Then, click Delete.
- If no trigger is configured for the function or the triggers configured for the function
are deleted, click Delete in the message that appears.
Additional information
Aside from the Function Compute console, you can use the following methods to manage functions in Function Compute:
- Serverless Devs
- SDKs For more information about API operation parameters, see Function.