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.
Log on to the Function Compute console.
Create a service. In this example:
Set Service Name to web-server and Region to China East 2 (shanghai).
Enable Advanced Settings.
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.
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.
In the left-side navigation pane, select the service that you created.
Click Create Function. On the displayed page, follow these steps:
Select nodejs8 or python2.7 from the language selection drop-down list. In this example, both languages are selected.
Select the Empty Function template.
Set Trigger Type to HTTP Trigger, configure it as follows, and then click Next.
Set Authorization to anonymous. This mode supports anonymous access and does not require authentication.
Set Method to a request method that is supported by the required function. For example, GET and POST.
Create a function and set the service name, function name, description, and runtime environment.
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.