All Products
Search
Document Center

Using version in trigger

Last Updated: Dec 08, 2018

Function Compute provides a wide variety of triggers to allow users to manage different event sources in a unified manner in an event-driven computing model. You can find more details in Trigger. You can specify the version and alias in the trigger through “qualifier” property, and if the rules defined by the trigger are met, the event source invokes the function under the specified version or alias.

The following triggers support versioning:

Trigger type
HTTP trigger
Time trigger
CDN events trigger
Log Store trigger
API Gateway trigger

Please refer trigger type for more trigger information.

Qualifier in the trigger

In the basic information of the trigger, the “qualifier” is an optional field, to store the service version pointed to by the trigger. The value can be either a version or an alias. If not specified, the trigger points to the LATEST version. Note that the trigger itself does not have a version, the trigger can point to a specific service version or alias.

How to set or modify qualifier in trigger

The qualifier is set when the trigger is created and modified. For detailed trigger operation, please refer to Addition and deletion of the trigger.

Set qualifier through console

When creating trigger(which supports versioning), specify version number or alias name in “Version/Alias” field.createtrigger

Set qualifier through fcli

  1. // Create Trigger
  2. fcli trigger create -s myService -f myFunction -q prod -t myTrigger
  3. // Update Trigger
  4. fcli trigger update -s myService -f myFunction -q 1 -t myTrigger

Best Practise of Trigger and Alias

With aliases and triggers, your CI and CD process can be better integrated with Function Compute. Here is the recommended workflow:

  1. Create a service and keep working on the LATEST version.
  2. When the LATEST version is ready, publish a version.
  3. Create an alias Prod pointing to the version, and create a trigger pointing to the alias Prod.wf1
  4. Continue to develop on the LATEST version and publish new version when it is stable.
  5. Update the alias Prod pointing to the new version, then all the events matching trigger rules will invoke the new version.wf2