This topic describes how to deploy an Express application to Function Compute. Function Compute provides a method different from traditional deployment methods. You can deploy a traditional Express application to Function Compute and use the application for production without performing operations such as purchasing a server. The deployed Express application can use the auto scaling, pay-as-you-go, and O&M-free features of Function Compute.


The following operations are complete:

Background information

Express is a minimal and flexible Node.js web application framework that provides a set of robust features to help you create various web and mobile applications.


  1. Run the following command in the specified directory to initialize a project:
    s init devsapp/start-express -d start-express
    The -d parameter specifies the project name. In this example, the project name is start-express.
    Note Skip this step if the item exists.
    Sample command output:
     Serverless Awesome:
     devsapp! file decompression completed
     Do you want to install dependencies? No
     please select credential alias default
        |  ___|
        | |____  ___ __  _ __ ___  ___ ___
        |  __\ \/ / '_ \| '__/ _ \/ __/ __|
        | |___>  <| |_) | | |  __/\__ \__ \
        \____/_/\_\ .__/|_|  \___||___/___/
                  | |
        Welcome to the start-express application
         This application requires to open these services:
             FC :
         This application can help you quickly deploy the Express project:
             Full yaml configuration :
             Express development docs:
         This application homepage:
     Thanks for using Serverless-Devs
     You could [cd /test/start-express] and enjoy your serverless journey!
    ️ If you need help for this example, you can use [s -h] after you enter folder.
     Document Star:
  2. Run the following command to go to the project directory:
    cd start-express
  3. Run the following command to deploy the project:
    s deploy
    Sample command output:
    [2021-09-03T10:48:50.558] [INFO ] [S-CLI] - Start ...
    [2021-09-03T10:48:50.567] [INFO ] [S-CLI] - Start the pre-action
    [2021-09-03T10:48:50.568] [INFO ] [S-CLI] - Action: npm install --production
    npm WARN app-express@0.0.1 No repository field.
    up to date in 0.463s
    [2021-09-03T10:48:51.442] [INFO ] [S-CLI] - End the pre-action
      Using web framework type: nas, If you want to deploy with container, you can [s cli fc-default set web-framework container] to switch.
    [2021-09-03T10:48:52.181] [WARN ] [EXPRESS] - [] The file already exists and will be used as the startup file.
      Using web framework type: nas, If you want to deploy with container, you can [s cli fc-default set web-framework container] to switch.
    (node:32096) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
    (Use `node --trace-deprecation ...` to show where the warning was created)
      End of request
      End of request
    [2021-09-03T10:48:56.897] [INFO ] [FC-DEPLOY] - Using region: cn-shenzhen
    [2021-09-03T10:48:56.897] [INFO ] [FC-DEPLOY] - Using access alias: default
    [2021-09-03T10:48:56.898] [INFO ] [FC-DEPLOY] - Using accessKeyID: 188077086902****
    [2021-09-03T10:48:56.898] [INFO ] [FC-DEPLOY] - Using accessKeySecret: KdcUEJLoGto****
      Using fc deploy type: sdk, If you want to deploy with pulumi, you can [s cli fc-default set deploy-type pulumi] to switch.
    [2021-09-03T10:48:57.268] [INFO ] [FC-DEPLOY] - Checking Service serverless-devs-express exists
    [2021-09-03T10:48:57.430] [INFO ] [FC-DEPLOY] - Setting role: AliyunFCDefaultRole
    [2021-09-03T10:48:57.577] [INFO ] [RAM] - Checking Role AliyunFCDefaultRole exists
    [2021-09-03T10:48:57.707] [INFO ] [RAM] - Updating role: AliyunFCDefaultRole
    [2021-09-03T10:48:57.816] [INFO ] [RAM] - Checking Plicy AliyunFCDefaultRolePolicy exists
    [2021-09-03T10:48:57.936] [INFO ] [FC-DEPLOY] - Using vpcConfig: auto: fc will try to generate related vpc resources automatically
    [2021-09-03T10:48:58.382] [INFO ] [VPC] - Getting vpc: fc-deploy-component-generated-vpc-cn-shenzhen
    [2021-09-03T10:48:58.474] [INFO ] [VPC] - Getting vswitch: fc-deploy-component-generated-vswitch-cn-shenzhen
    [2021-09-03T10:48:58.603] [INFO ] [VPC] - Getting securityGroup: fc-deploy-component-generated-securityGroup-cn-shenzhen
    [2021-09-03T10:48:58.773] [INFO ] [FC-DEPLOY] - Generated vpcConfig:
    securityGroupId: sg-wz92ctigpi221smc****
    vSwitchId: vsw-wz9qnuult4q5g4f7n****
    vpcId: vpc-wz9x9bzs0wtvjgt6n****
    [2021-09-03T10:48:58.774] [INFO ] [FC-DEPLOY] - Using nasConfig: auto: fc will try to generate related nas file system automatically
    [2021-09-03T10:49:16.121] [INFO ] [FC-DEPLOY] - Generated nasConfig:
    groupId: 10003
      - fcDir: /mnt/auto
        nasDir: /serverless-devs-express
    userId: 10003
    [2021-09-03T10:49:16.123] [INFO ] [FC-DEPLOY] - Checking Function express exists
    [2021-09-03T10:49:16.229] [WARN ] [FC-DEPLOY] - Image dose not exist locally.
    Maybe you need to run 's build' first if it dose not exist remotely.
    [2021-09-03T10:49:16.232] [INFO ] [FC-DEPLOY] - Checking Trigger serverless-devs-express exists
    [2021-09-03T10:49:16.294] [INFO ] [FC-DEPLOY] - Checking Trigger serverless-devs-express exists
    [2021-09-03T10:49:16.400] [INFO ] [FC-DEPLOY] - Creating service: serverless-devs-express
    [2021-09-03T10:49:16.400] [INFO ] [FC-DEPLOY] - Creating function: express
    [2021-09-03T10:49:16.401] [INFO ] [FC-DEPLOY] - Creating triggers: ["serverless-devs-express"]
      Make service serverless-devs-express success.
      Make function serverless-devs-express/express success.
      Make trigger serverless-devs-express/express/serverless-devs-express success.
    [2021-09-03T10:49:19.389] [INFO ] [FC-DEPLOY] - Checking Service serverless-devs-express exists
    [2021-09-03T10:49:19.450] [INFO ] [FC-DEPLOY] - Checking Function express exists
    [2021-09-03T10:49:19.569] [INFO ] [FC-DEPLOY] - Checking Trigger serverless-devs-express exists
    [2021-09-03T10:49:19.750] [INFO ] [FC-DEPLOY] - Creating custom domain: express.serverless-devs-express.188077086902****
    [2021-09-03T10:49:20.364] [INFO ] [FC-DOMAIN] - Creating custom domain: express.serverless-devs-express.188077086902****
    There is auto config in the service: serverless-devs-express
    [2021-09-03T10:49:20.472] [INFO ] [WEB-FRAMEWORK] - nas component get src is: .
    Packing ...
    file /test/start-express/.s is ignored.
    Package complete.
     Start uploading file: /mnt/2bfb748534-tpm20-cn-shenzhen/serverless-devs-express/express/
      File uploaded successfully: /mnt/2bfb748534-tpm20-cn-shenzhen/serverless-devs-express/express/
      upload done
    [2021-09-03T10:50:13.196] [INFO ] [FC-NAS] - unzipping file
    [2021-09-03T10:50:16.431] [INFO ] [FC-NAS] - unzip done
      Try container acceleration
      region: cn-shenzhen
      serviceName: serverless-devs-express
      functionName: express
        - >-


After the project is deployed, you can view the temporary domain name generated by Function Compute in the execution output. The temporary domain name can be used to access the newly deployed application. For example, run the following command to access the application:

curl http://express.serverless-devs-express.188077086902****
Note The temporary domain name is used only for demonstration and development purposes. It is valid for a limited period of time. You must use a domain name that has obtained an Internet Content Provider (ICP) filing from Alibaba Cloud for production. For more information, see Configure a custom domain name.