tencent cloud


Function Operations

Last updated: 2022-01-06 10:33:02


    This document describes how to quickly create, configure, and deploy an SCF application in Tencent Cloud through Serverless Framework.



    If your account is a Tencent Cloud sub-account, get the authorization from the root account first as instructed in Account and Permission Configuration.


    Quick deployment

    In an empty folder directory, run the following command:


    Next, follow the interactive prompts to initialize the project. Select the scf-starter template for the application and select the runtime you want to use (Node.js is used as an example here):

    Serverless: No serverless project is detected. Do you want to create one? Yes
    Serverless: Please select the Serverless application you want to create: scf-starter - quickly deploys an SCF function
      react-starter - quickly deploys a React.js application 
     restful-api - quickly deploys a RESTful API to use Python + API Gateway 
    ❯ scf-starter - quickly deploys an SCF function 
     vue-starter - quickly deploys a basic Vue.js application 
     website-starter - quickly deploys a static website 
     eggjs-starter - quickly deploys a basic Egg.js application 
     express-starter - quickly deploys a basic Express.js application 
    Serverless: Please select the runtime of the application: scf-nodejs - quickly deploys an SCF function in Node.js
      scf-golang - quickly deploys an SCF function in Go 
    ❯ scf-nodejs - quickly deploys an SCF function in Node.js 
     scf-php - quickly deploys an SCF function in PHP 
     scf-python - quickly deploys an SCF function in Python  
    Serverless: Please enter the project name: demo
    Serverless: Installing the scf-nodejs application...
    scf-nodejs › Created
    The demo project has been successfully created!

    Select Deploy Now to quickly deploy the initialized project to the SCF console:

    Serverless: Do you want to deploy the project in the cloud now? Yes
    x  QR  x
    x CODE x
    serverless ⚡ framework
    Action: "deploy" - Stage: "dev" - App: "scfApp" - Instance: "scfdemo"
    functionName: helloworld
    description:  helloworld blank template function
    namespace:    default
    runtime:      Nodejs10.15
    handler:      index.main_handler
    memorySize:   128
    lastVersion:  $LATEST
    traffic:      1
      - http://service-xxxxxxx.gz.apigw.tencentcs.com/release/
    27s › scfdemo › Success

    After deployment, complete the remote invocation of the function by running the following command:

    sls invoke --inputs function=helloworld

    sls is short for the serverless command.

    Viewing deployment information

    If you want to check the deployment status and resources of the application again, you can go to the folder where the project is successfully deployed and run the following command to view the corresponding information:

    cd demo # Enter the project directory. Please change to your actual project's directory name here
    sls info

    Viewing directory structure

    In the directory of the initialized project, you can see the most basic structure of a serverless function project:

    ├── serverless.yml  # Configuration file
    ├—— index.js    # Entry function
    └── .env # Environment variable file
    • The serverless.yml configuration file implements the quick configuration of the basic function information. All the configuration items supported by the SCF console can be configured in the .yml file (for more information, see SCF Configuration Information).
    • index.js is the entry function of the project, which is the helloworld template here.
    • The .env file stores user login authentication information. You can also configure other environment variables in it.


    In the local project directory, you can modify the function template and configuration file and then redeploy the project by running the following command:

    sls deploy

    If you want to view the details during the removal process, you can add the --debug parameter.

    Continuous development

    After the deployment is completed, Serverless Framework supports running different commands to help you implement continuous development, deployment, and grayscale release for the project. You can also use this component in conjunction with other components to manage the deployment of multi-component applications.

    For more information, see Application Management and List of Supported Commands.


    the wizard does not pop up by default when serverless is entered.

    Solution: add the SERVERLESS_PLATFORM_VENDOR=tencent configuration item to the .env file.

    after sls deploy is entered in a network environment outside the Chinese mainland, the deployment is very slow.

    Solution: add the GLOBAL_ACCELERATOR_NA=true configuration item to the .env file to enable acceleration outside the Chinese mainland.

    after sls deploy is entered, the deployment reports a network error.

    Solution: add the following proxy configuration to the .env file.

    HTTP_PROXY= # Replace "12345" with your proxy port
    HTTPS_PROXY= # Replace "12345" with your proxy port

    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support