Creating Triggers

Last updated: 2020-02-26 18:50:25


After created, you can create a trigger to associate a 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 TCCLI.

Creating a Trigger in the Console

  1. Log in to the SCF Console And click Function Service On the left sidebar.
  2. At the top of the function Services list page, select the region and namespace where you want to create the trigger function.
    The function list includes the function name, monitoring, running environment, creation time, modification time, and so on. You can operate according to your own needs.
  3. Click a function name to enter the function details page.
    The function details page includes the function configuration page, the function code page, the trigger method page, the running log page and the monitoring information page.
  4. Select the "Triggers" tab and click Add a trigger .
  5. In show more's "add trigger method" form, you can select a different trigger method in [trigger method]. If you choose different trigger methods, the content of Enter will be different.
    For a scheduled trigger, you need to enter the trigger name, cycle, and enablement for a timer trigger. For a COS trigger, you need to enter COS bucket, event type, and prefix/suffix filters.

For a more specific description of the trigger related to Enter, you can see each Trigger The documentation for the.
7. After complete the configuration, click Save To create the trigger.
To cancel the creation process, click Cancel .

Complete trigger creation through the SCF command line

Before starting, you need to install and configure SCF CLI by following instructions in CLI installation and configuration .

Local functions can be found in the template.yaml Add a description of the trigger under the file. For more information on the description rules, please see Event source type And then executed through the SCF command line scf deploy Command, you can add triggers to the function. For more information, please see Packaged deployment .

Version and Trigger

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 of the specified version.

When creating such a triggerin the console, you can switch to the desired version by choosing it in the version list at the upper right corner of the function interface, and then create the trigger on the triggering method tab; when creating through TCCLI, you can specify the desired version on which to create the trigger by including a version number parameter.

To increase the trigger limits, please Contact us .