tencent cloud

Feedback

Create and Update a Function

Last updated: 2022-07-21 11:22:21

    Tencent Cloud SCF allows you to create and update a function as needed in multiple ways.

    Creating a Function

    Creating function in the console

    1. Log in to the SCF console and click Functions on the left sidebar.
    2. Select the region where to create a function at the top of the page and click Create to enter the function creation process.
    3. Select Custom or Template to create a function.
    • If you select Custom, you need to enter the required function name and runtime environment to create the function.
    • If you select Template, you need to enter the required function name, runtime environment, and configuration items in the function template to create the function.

    Creating function in other ways

    You can create a function as needed in more ways as detailed below:

    • Use Serverless Framework CLI to create a function. For more information, see Creating Function on CLI and relevant function invocation and deployment documents.

    Function Configuration Update

    Updating function configuration in the console

    1. Log in to the SCF console and click Functions on the left sidebar.
    2. Select the region of the function to be updated at the top of the page and click the target function in the list to enter the function details page.
    3. Switch to the function configuration page and click Edit in the top-right corner to enter the editing mode.
    4. Modify the description, memory, timeout, environment variable, and network configuration of the function as needed.
    5. After completing the modification, click Save.
      To cancel the modification, click Cancel.

    Updating function configuration on Serverless Framework CLI

    1. To modify the function configuration, directly modify the serverless.yml configuration file under the function root directory as shown below:
    # serverless.yml
    component: scf # Name of the imported component, which is required. The `tencent-scf` component is used in this example
    name: scfdemo # Name of the instance created by this component, which is required
    inputs:
    name: scfFunctionName
    src: ./src
    runtime: Nodejs10.15 # Runtime environment of function. Valid values: Python2.7, Python3.6, Nodejs6.10, Nodejs8.9, Nodejs10.15, Nodejs12.16, PHP5, PHP7, Golang1, Java8
    region: ap-guangzhou
    handler: index.main_handler
    events:
      - apigw:
          name: serverless_api
          parameters:
            protocols:
              - http
              - https
            serviceName:
            description: The service of Serverless Framework
            environment: release
            endpoints:
              - path: /index
                method: GET
    
    1. After completing the modification, run sls deploy on Serverless Framework CLI to deploy the function.

    Function Code Update

    Updating function code in the console

    1. Log in to the SCF console and click Functions on the left sidebar.
    2. Select the region of the function to be updated at the top of the page and click the target function in the list to enter the function details page.
    3. Switch to the function code page and edit the function code in the following way:
    • For scripting languages: You can directly use the function code editor.
    • For non-scripting languages: You can submit the function code by uploading a zip package or through COS and then edit it.
    1. After completing the modification, click Save.
      To cancel the modification, click Cancel.

    Updating function code on Serverless Framework CLI

    After the function code is modified locally, run sls deploy on Serverless Framework CLI to deploy the function and update the code.

    Note:

    The development mode of Serverless Framework supports updating functions synchronously. For more information, see Development Debugging.

    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