All Products
Search
Document Center

Trigger operation

Last Updated: May 31, 2019

Triggers are used to call function execution. For example, if an OSS trigger is configured for a function, the function is executed when an object in OSS is created or (the actual action is specified when the trigger is configured). If a Timer trigger is configured, function execution is triggered at the specified time.

Different triggers require different configurations. For more information, see the following topics OSS trigger, HTTP trigger, and Timer trigger.

Contents

This topic describes how to create, update, query, or delete a trigger using the console or the command-line tool fcli.

Create a trigger in the console

You can create a trigger when you create a function. For more information, see Create a trigger when a function is created. If you create a trigger after a function is created, follow these steps:

  1. Log on to the console.

  2. Select a region.

  3. Select a service.

  4. Select a function.

  5. Click the Trigger tab and click Create Trigger.

    Trigger

Update a trigger in the console

  1. Log on to the console.

  2. Select a region.

  3. Select a service.

  4. Select a function.

  5. Click the Trigger tab and click one of your triggers.

    UpdateTrigger

You can update and modify the trigger properties in the Edit Trigger dialog box.

Query a trigger in the console

  1. Log on to the console.

  2. Select a region.

  3. Select a service.

  4. Select a function.

  5. Click the Trigger tab, you can see all the triggers in the specified functions.

Delete a trigger in the console

  1. Log on to the console.

  2. Select a region.

  3. Select a service.

  4. Select a function.

  5. Click the Trigger tab, find the trigger and click Delete under the Actions column.

    DeleteTrigger

  6. Click OK to confirm the action.

Create a trigger by using fcli

mkt: creates a trigger.

  • -r —invocation-role string: Sets a role to trigger a function.
  • -s —source-arn string: Specifies the event source, such as acs:oss:cn-shanghai:12345678:myBucketName.
  • -c —trigger-config string: Sets the configuration file of a trigger.
  • -t —type string: Specifies the trigger type. The default value is OSS.
  1. >>> mkt myFunction/myFunctionTrigger -t oss -r acs:ram::account_id:role/AliyunOSSEventNotificationRole -s acs:oss:cn-region:account_id:bucketName -c code/trigger.yaml
  2. //Example
  3. >>> mkt myFunction/myFunctionTrigger -t oss -r acs:ram::12345678:role/AliyunOSSEventNotificationRole -s acs:oss:cn-shanghai:12345678:myOssBucket -c code/ossTrigger.yaml
  4. //Details of the .yaml file are as follows:
  5. triggerConfig:
  6. events:
  7. - oss:ObjectCreated:PutObject
  8. - oss:ObjectRemoved:DeleteObject
  9. filter:
  10. key:
  11. prefix: myPrefix
  12. suffix: mySuffix

Update a trigger by using fcli

upt: Updates the trigger. The parameters of the upt function are the same as the parameters of the mkt function.

  1. >>> upt myFunction/myFunctionTrigger -t oss -r acs:ram::account_id:role/AliyunOSSEventNotificationRole -s acs:oss:cn-region:account_id:bucketName -c code/trigger.yaml

Query a trigger by using fcli

To view all triggers of a function, run the ls command.

Delete a trigger by using fcli

To delete a trigger under a function, run the rm triggerName command.