All Products
Search
Document Center

Function Compute:Create a web function

Last Updated:Dec 07, 2025

You can create a web function to write programs that use popular frameworks, such as Flask, Express, or SpringBoot, or to migrate existing framework applications to Function Compute. Function Compute schedules and runs resources at the function level. Functions are independent of each other. This topic describes how to create and manage web functions in the console.

Create a function

  1. Log on to the Function Compute console. In the navigation pane on the left, choose Function Management > Function List.

  2. In the top menu bar, select a region. On the Function List page, click Create Function.

  3. In the dialog box that appears, select the Web Function type and click Create Web Function.

  4. On the Create Web Function page, set the following configuration items, and then click Create.

    • Basic Configurations: Set the function specifications and instance information.

      Configuration Item

      Description

      Example

      Function Name

      A unique symbol to identify the function. The function name must be unique within the same account and region and comply with naming conventions.

      myFunction

      Specification Plan

      Set the vCPU, Memory, and Disk specifications for the function based on your business needs. After you set the specifications, the usage of each resource is billed based on the specification multiplied by the usage duration. For more information, see Billing overview.

      Note
      • The ratio of vCPU cores to memory in GB must be between 1:1 and 1:4.

      • All directories on the disk are writable. The disk space is shared.

      • The disk size is tied to the instance lifetime of the underlying function. Data on the disk is lost when the instance is reclaimed by the system. To store files with persistence, you can mount a NAS file system or an OSS bucket. For more information, see Configure a NAS file system and Configure OSS.

      • vCPU: 0.35 vCPU

      • Memory: 512 MB

      • Disk: 512 MB (not billed, Function Compute provides a free quota of 10 GB disk space)

      Concurrency Per Instance

      You can configure multiple concurrent requests for a single web function instance. This means a single function instance can process multiple requests simultaneously. For more information, see Configure concurrency per instance.

      20

    • Elastic Configurations: Select an elastic mode.

      Parameter

      Description

      Example

      Minimum Instances

      If your business is sensitive to latency, set **Minimum Instances** to 1 or higher. This pre-allocates resources and reduces cold start latency.

      Note
      • If you set **Minimum Instances** to 1 or higher, and no elastic policy for minimum instances is configured or valid for a period, the current number of minimum instances is the value you set here.

      • If you configure multiple elastic policies, the system calculates the Minimum Instances for each policy when it is triggered. The system then uses the highest value among the valid policies as the current Minimum Instances.

        For more information, see How is the current number of minimum instances calculated?.

      Enabled

    • Function Code: Configure the function's runtime and code information.

      Configuration Item

      Description

      Example

      Runtime

      Select Custom Runtime and choose a familiar language or framework. For more information, see Code development overview.

      Custom Runtime > Node.js > Node.js 16

      Code Upload Method

      Select how to upload code to Function Compute.

      • Use Sample Code: The default method. Select sample code provided by Function Compute to create a function.

      • Upload A ZIP Package: Select and upload a ZIP package that contains the function code.

      • Upload A Folder: Select and upload a folder that contains the function code.

      • Upload From OSS: Select the Bucket Name and File Name of the function code to upload.

      Use Sample Code

      Startup Command

      The startup command for the program. If you do not configure a startup command, manually create a startup script named `bootstrap` in the root directory of your code. The program uses this script to start.

      npm run start

      Listening Port

      The port that the HTTP server in the code listens on.

      9000

      Execution Timeout

      Set the timeout period. The default Execution Timeout is 60 seconds. The maximum value is 86,400 seconds.

      60

    • Permissions, Network, and Storage: Configure the function's access role, network settings, and storage mounts.

      Parameter

      Description

      Example

      Function Role

      The Function Compute platform uses this RAM role to generate temporary keys for accessing Alibaba Cloud resources and passes them to the code. For more information, see Use a function role to grant Function Compute permissions to access other Alibaba Cloud services.

      mytestrole

      Allow Access To VPC

      Enable this to allow the function to access resources in a VPC. For more information, see Configure network settings.

      Enabled

      VPC

      Required if you set Allow Access To VPC to Yes. Create a new VPC or select a VPC ID from the drop-down list.

      fc.auto.create.vpc.1632317****

      VSwitch

      Required if you set Allow Access To VPC to Yes. Create a new vSwitch or select a vSwitch ID from the drop-down list.

      fc.auto.create.vswitch.vpc-bp1p8248****

      Security Group

      Required if you set Allow Access To VPC to Yes. Create a new security group or select a security group from the drop-down list.

      fc.auto.create.SecurityGroup.vsw-bp15ftbbbbd****

      Allow Default NIC To Access Public Network

      Allow the function to access the public network through the default network interface card.

      Important

      When you use a static public IP address, you must disable Allow Default NIC To Access Public Network. Otherwise, the configured static public IP address does not take effect. For more information, see Configure a static public IP address.

      Enabled

      Mount NAS File System

      Mount a NAS file system to the function for persistent storage of shared data, such as models shared by multiple inference functions. For more information, see Configure a NAS file system.

      If you select automatic configuration, the system uses an existing General-purpose NAS file system named Alibaba-Fc-V3-Component-Generated. If a qualifying NAS file system does not exist in your account, the system creates one.

      Enabled

      Mount OSS Object Storage

      Mount an OSS bucket to the function for persistent storage of logs, business files, and other data. For more information, see Configure Object Storage Service (OSS).

      Enabled

    • Logs And Tracing Analysis

      Parameter

      Description

      Example

      Log Feature

      Persistently save the function's execution logs to Simple Log Service. This helps with code debugging, troubleshooting, and data analytics. For more information, see Configure the logging feature.

      • Automatic Configuration: Automatically selects a log project that starts with serverless-<region_id>.

        Only one such log project is created in each region. If the system finds that this log project already exists in the current region, it uses the existing project.

      • Custom Configuration: Manually specify the destination Log Project and Logstore.

      Enabled

    • More Configurations

      Parameter

      Description

      Example

      Time Zone

      Select the time zone for the function. This automatically adds the TZ environment variable to the function with the selected time zone as its value.

      UTC

      Tags

      Set tags for the function to group and manage functions. You must set both a tag key and a tag value.

      key : value

      Resource Group

      Select the resource group for the function. Use resource groups to manage your functions in groups.

      Default Resource Group

      Environment Variables

      Use environment variables to flexibly adjust the function's behavior without changing the code. For more information, see Configure environment variables.

      {
          "BUCKET_NAME": "MY_BUCKET",
          "TABLE_NAME": "MY_TABLE"
      }

Edit a function

You can edit, import, or export function code. To change other configuration items, see Configure a function.

  1. On the Function Details page, you can change the function code on the Code tab. If the branch on the left indicates a change (① in the figure), you must first click Deploy Code to apply your changes. Then, click Test Function.

    image

  2. You can also export your code as a backup or upload new code for deployment.

    image

    image

Delete a function

Log on to the Function Compute console. On the Function List page, find the function you want to delete and click Delete in the Actions column. In the dialog box that appears, confirm that the function has no attached resources, such as triggers or elastic policies for minimum instances. Then, confirm the deletion.

Get the function ARN

An Alibaba Cloud Resource Name (ARN) is used to identify an Alibaba Cloud resource in your code. You can obtain the ARN of a function to reference it.

  1. Log on to the Function Compute console. In the navigation pane on the left, choose Function Management > Function List.

  2. In the top menu bar, select a region. Then, on the Function List page, click the name of the function.

  3. On the Function Details page, click Copy ARN on the right to obtain the ARN of the target function.

    image

References