After creating a function, you can create a trigger to associate the function with an event source. The associated event source will trigger the function synchronously or asynchronously as specified when an event is generated, and the event will be passed to the entry function as an input parameter upon triggering.
A function trigger can be created in the console or through Serverless Cloud Framework.
Only API Gateway triggers can be created for HTTP-triggered functions. For more information, please see Creating HTTP-Triggered Function.
Log in to the SCF console and select Function Service on the left sidebar.
At the top of the Function Service page, select the region and namespace where the function for which to create a trigger resides as shown below:
The function list contains the function name, monitoring information, runtime environment, creation time, and modification time.
Click the function name to enter the function details page.
The function details page contains the function management, trigger management, monitoring information, log query, and concurrency quota tabs:
On the function details page, select Trigger Management on the left to enter the trigger browsing and operation page. Click Create a Trigger to create a trigger as shown below:
In the Create a Trigger pop-up window, you can select different trigger methods in Trigger Method. The information to be entered varies by trigger method.
For example, for a timer trigger, you need to enter the trigger name, cycle, and status. For a COS trigger, you need to enter the COS bucket, event type, and prefix/suffix filters.
For more information on what to enter for specific triggers, please see the applicable documents of triggers.
After completing the trigger configuration, click Submit to create the trigger.
To cancel the creation process, click Close.
Before starting, please install the Serverless Cloud Framework tool first as instructed in Installing Serverless Cloud Framework.
For local functions, please add the trigger description in the
serverless.yml file. Then, run the
scf deploy command on Serverless Cloud Framework to add a trigger to the function.
A trigger can be created on a specified version of a function. An event of the trigger created in this manner will trigger the code on the specified version.
When creating such a trigger in the console, you can switch to the desired version by choosing it in the version list in the top-right corner on the function page and then create the trigger on the "Triggers" tab.
There are certain quota limits for the total number of triggers and number of triggers in each type for a function. Based on the function configuration, triggers created on different versions take up the quota of the function. To increase the limit, please contact us for application.