All Products
Document Center

1. Create HTTP trigger

Last Updated: Oct 16, 2018

In the following example, an HTTP trigger is created when you create a function. You can either create an HTTP trigger when creating a function, or after the function is created. However, we recommend that you create an HTTP trigger during function creation, because when you create a function, the console provides you with a default handler. It prevents you from using the original function handler and generating errors.

Configure HTTP trigger while creating function

  1. Log on to the Function Compute console.

  2. Create a service. In this example:

    1. Set Service Name to web-server and Region to China East 2 (shanghai).

    2. Enable Advanced Settings.

    3. In the Log Configs area, set Log Project and LogStore.

      Log data of functions is collected to a Logstore so that you can more easily debug issues. For more information about logs, see Function logs.

    4. In the Role Config area, set Role Operation to Create new role, set System Policies to AliyunLogFullAccess, click Authorize, and then click OK.

      In this example, the role is granted the permission to access other Alibaba Cloud services. For more information about permissions, see RAM.

  3. In the left-side navigation pane, select the service that you created.

  4. Click Create Function. On the displayed page, follow these steps:

    1. Select nodejs8 or python2.7 from the language selection drop-down list. In this example, both languages are selected.

    2. Select the Empty Function template.

    3. Set Trigger Type to HTTP Trigger, configure it as follows, and then click Next.

      1. Set Authorization to anonymous. This mode supports anonymous access and does not require authentication.

      2. Set Method to a request method that is supported by the required function. For example, GET and POST.

    4. Create a function and set the service name, function name, description, and runtime environment.

    5. Click Next.

    6. Verify that all settings are correct and click Create.


For more information about how to create an HTTP trigger after a function is created, see Basic operations.

For more information about how to create a service in the console, see Create a service.

Next step

Compile function code.