All Products
Search
Document Center

Function Compute:Create a web function

Last Updated:Apr 16, 2026

To run applications built on popular frameworks like Flask, Express, or Spring Boot, or to migrate existing framework-based applications to Function Compute, you can create a web function. In Function Compute, resources are scheduled and run on a per-function basis. Each function is independent and isolated. This topic explains how to create and manage web functions in the Function Compute console.

Create a function

  1. Log in to the Function Compute console. In the left-side navigation pane, choose Function Management > Functions.

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

  3. In the dialog box that appears, select Web Function, and then click Create a web function.

  4. On the Create a web function page, configure the following settings, and then click Create.

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

      Parameter

      Description

      Example

      Function Name

      A unique identifier for the function. The name must be unique within a region for your Alibaba Cloud account and follow the naming conventions.

      myFunction

      Specifications

      Set the vCPU, Memory, and Disk specifications for the function based on your workload. You are billed for resource usage based on these specifications and the execution duration. For more information, see Billing overview.

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

      • All directories on the disk are writable, and the disk space is shared among all function instances.

      • Data on the disk is ephemeral and is lost when the instance is reclaimed. To persist files, 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 for disk space.)

      Instance Concurrency

      Set the number of concurrent requests that a single function instance can process. For more information, see Configure concurrency per instance.

      20

    • Scaling Policy: Select an elasticity mode.

      Parameter

      Description

      Example

      Minimum Instances

      For latency-sensitive workloads, set minimum instances to 1 or higher. This pre-allocates resources to reduce cold start latency.

      Note
      • If you set this value to 1 or higher, Function Compute maintains that number of provisioned instances, unless an active elasticity policy for minimum instances requires more.

      • When multiple elasticity policies are active, the system evaluates the required Minimum Instances for each. The highest value among the active policies becomes the current number of Minimum Instances.

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

      Enabled

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

      Parameter

      Description

      Example

      Runtime

      Select Custom Runtime and choose a programming language or framework that you are familiar with. For more information, see Code development overview.

      Custom Runtime

      Code Upload Method

      Select a method to upload your code.

      • Use Sample Code: The default option. You can select sample code provided by Function Compute based on your business requirements.

      • Upload ZIP: Select and upload a ZIP package that contains your function code.

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

      • OSS: Specify the Bucket Name and Object Name of the function code package in OSS.

      Use Sample Code

      Startup Command

      If you do not specify this command, you must provide a startup script named bootstrap in the root directory of your code to start the application.

      npm run start

      Listening Port

      The port on which the HTTP server in your code listens.

      9000

      Execution Timeout Period

      The timeout period for function execution. The default value of Execution Timeout Period is 60 seconds, and 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

      Function Compute assumes this Resource Access Management (RAM) role to obtain temporary credentials for accessing other Alibaba Cloud services. These credentials are then passed to your function's code. For more information, see Grant Function Compute permissions to access other cloud services by using a function role.

      mytestrole

      Access to VPC

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

      Enabled

      VPC

      Required if Access to VPC is enabled. Select an existing VPC or create a new one.

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

      vSwitch

      Required if Access to VPC is enabled. Select an existing vSwitch or create a new one.

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

      Security Group

      Required if Access to VPC is enabled. Select an existing security group or create a new one.

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

      Allow Default NIC to Access Internet

      Allows the function to access the public network through its default network interface card (NIC).

      Important

      If you use the static public IP address feature, you must disable Allow access to public network from default NIC. Otherwise, the configured static public IP address does not take effect. For more information, see Configure a static public IP address.

      Enabled

      Mount a NAS File System

      Configure a NAS file system for the function to persist and share data across functions, such as a model shared by multiple inference functions.

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

      Enabled

      Mount OSS

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

      Enabled

    • Logging and tracing

      Parameter

      Description

      Example

      Logging

      Saves function execution logs to Simple Log Service. You can use these logs for debugging, troubleshooting, and data analytics. For more information, see Configure logging.

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

        Only one such log project is created per region. If the system finds an existing log project in the current region, it uses that project directly.

      • Custom Configuration: You must manually specify the destination Log Service Project and Logstore.

      Enabled

    • More Configurations

      Parameter

      Description

      Example

      Time zone

      Select the time zone for the function. After you set the time zone, the system automatically adds a TZ environment variable to the function, with its value set to the selected time zone.

      UTC

      Tag

      Add tags to the function to group and manage resources. You must specify both a tag key and a tag value.

      key: value

      Resource Group

      Select a resource group for the function to organize and manage your resources.

      Default Resource Group

      Environment Variables

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

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

Edit a function

On the Function Details page, use the Code tab to modify your function code directly in the console. You can also export code as a backup or upload new code.

If the left panel shows uncommitted changes (indicated by ①), click Deploy before clicking Test Function to apply your changes.
image

To export or upload code:

imageimage

For other configuration changes such as instance specifications and scaling, see Function instance specifications and elastic configurations.

Delete a function

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

  2. Locate the function and click Delete in the Actions column.

  3. In the confirmation dialog, verify that the function has no attached resources (such as triggers or minimum-instance elastic policies), then confirm the deletion.

Get the ARN of a function

An Aliyun Resource Name (ARN) uniquely identifies an Alibaba Cloud resource and lets you reference functions from code or other services.

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

  2. In the top menu bar, select a region. Click the target function.

  3. On the Function Details page, click Copy ARN on the right.

image

Related topics