tencent cloud


Creating Event Function in Console

Last updated: 2022-11-01 10:58:16

    This document describes how to quickly create an event-triggered function in the console.
    Compared with event-triggered functions, the HTTP-triggered functions provided by SCF focus more on optimizing web services. Click here to understand and quickly create an HTTP-triggered function.

    Step 1. Sign up for a Tencent Cloud account

    If you already have a Tencent Cloud account, ignore this step.

    Step 2. Top up online

    SCF users are entitled to a certain free tier of resource usage and invocations each month as shown below. There is no free tier for public network outbound traffic. SCF is billed by the actual Tencent Cloud resource usage. If you need to use other postpaid Tencent Cloud resources, top up your account first as instructed in Payment Method before making purchases.

    Step 3. Authorize the service

    Log in to the Tencent Cloud console, select Products > Serverless Cloud Function to enter the SCF console, and follow the prompts to authorize SCF. (If you have already authorized SCF, skip this step.)

    Step 4. Create a function

    1. Click Functions on the left sidebar to enter the Functions page.
    2. Select Guangzhou at the top of the page and click Create as shown below:
    3. Enter the basic information of the function on the Create function page and click Next as shown below:
    • Creation method: Select Function template.
    • Filter: After entering helloworld, press "Enter" to search for and select the helloworld template. SCF supports multiple runtime environments. This function uses Python 2.7 as an example.
    1. The function name is automatically generated by default and can be modified as needed. Keep the default function configuration and click Complete as shown below:

      After the function is created, you will be automatically redirected to its Function configuration page where you can view its configuration information.
    2. Select the Function codes tab to view or edit the function code online as shown below:

    Step 5. Deploy the function (including trigger configuration)

    1. After editing the function code online, click Deploy, and the function will be deployed.
    2. On the details page of the created function, select Trigger management on the left and click Create trigger.
    3. In the Create trigger window that pops up, set Trigger method to API Gateway trigger, unselect Enable integration response, and keep other parameters as default as shown below:
    4. Click Submit to complete the function deployment and trigger configuration.

    Step 6. Test in the cloud

    On the Function management page, select Function codes and click Test to run the code with the test result returned as shown below:

    • If you need to replace the test template or its content, you can directly edit the function content or select Current test template, replace it, and then click Save.
    • Different test templates simulate different trigger message sources, and the messages passed between different triggers and SCF are data structures agreed upon in advance. For more information, see Trigger Overview.

    The returned result is as follows:

    During this test, SCF will get the data structures of the "Hello World event template" in the event parameter of the main_handler.

    "key1": "test value 1",
    "key2": "test value 2"

    Step 7. View logs and monitoring data

    On the details page of a created function, select Log Query on the left to view the detailed logs of the function as shown below:

    For more information on logs, see Viewing Execution Logs.

    Step 8. Delete the function

    After the function starts running, it consumes resources. In order to avoid unnecessary fees, this step shows you how to clear all resources.

    1. Select Functions on the left sidebar and click Delete on the right of the function to be deleted as shown below:
    2. Confirm the information in the Delete Function pop-up window and click OK.


    See General for solutions.
    If the problem persists, submit a ticket for assistance.

    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