Problem description
A trigger cannot trigger function execution.
Possible causes
The following items describe the possible causes:
The trigger event is not successfully generated.
The rules for triggering function execution are not met.
The role configured for the trigger is incorrect.
Solutions
Solution 1: Check whether the trigger event is generated
OSS triggers
For example, if you specify to trigger a function after an object is uploaded to Object Storage Service (OSS), perform the following steps to troubleshoot the issue:
Check whether the object is uploaded to the corresponding bucket.
If the object is correctly uploaded, check for the corresponding run log in Function Compute.
If the run log is found, the function is triggered. In this case, the function may have failed. You must debug your code based on the log.
If no run log is found, the function is not triggered. In this case, check whether the triggering rules are met. For more information, see Solution 2: Check whether the triggering rules are met.
If the file is not uploaded, upload the file.
Simple Log Service triggers
If Simple Log Service triggers fail to trigger function execution, you can troubleshoot the issue by performing the following steps:
Check whether incremental data changes occurred in the Logstore associated with the trigger. The associated function is triggered if the shard data changes.
Check for exceptions in the run logs of the function.
Solution 2: Check whether the triggering rules are met
The following items provide examples on some common triggering rules.
Time triggers
Check the triggering method and time system. You must check which time system is used by your trigger. If you set the triggering method to custom CRON expression, the Coordinated Universal Time (UTC) time is used by default. For more information, see Step 1: Create a time trigger.
If you set the CRON expression to 0 0 4 * * *, the function is triggered at 04:00 (UTC+0) or 12:00 (UTC+8) every day.
If you set the CRON expression to CRON_TZ=Asia/Shanghai 0 0 4 1 * *, the function is triggered at 04:00 (UTC+8) on the first day of each month.
OSS triggers
Your function and its associated OSS bucket must reside in the same region.
The prefix or suffix of an uploaded object must be the same as the object prefix or suffix that you configured for the trigger.
For example, if you set the object prefix to ab, and upload a/b.zip, ab.zip, and abc.zip to OSS, only ab.zip and abc.zip can trigger function execution.
The OSS event must be exactly the same as the configured trigger event. Otherwise, function execution cannot be triggered. The following items describe the cases in which the OSS event does not match the trigger event.
You upload an object by using ossbrowser and multipart upload. After the upload, the event is
oss:ObjectCreated:CompleteMultipartUpload
. If the trigger event that you configured isoss:ObjectCreated:PutObject
oross:ObjectCreated:PostObject
, function execution cannot be triggered.The event that you upload an object by using the console is
oss:ObjectCreated:PostObject
, but the trigger event that you configured isoss:ObjectCreated:PutObject
. The event that you upload a file by calling theoss:ObjectCreated:PutObject
operation isoss:ObjectCreated:PutObject
, but the trigger event that you configured isoss:ObjectCreated:PostObject
. In both cases, function execution cannot be triggered.
When you delete an object from a bucket for which versioning is enabled in OSS, you must specify the version ID.
If you do not specify the version ID when you use ossbrowser to delete an object, the
oss:ObjectRemoved:DeleteObject
oross:ObjectRemoved:DeleteObjects
event is not triggered. The current version of the object becomes a previous version, and a delete marker is added. For more information, see FAQ.EventBridge-based OSS triggers take effect 30 seconds after they are created.
Tablestore triggers
You must enable the Stream feature for the data table of a Tablestore instance. For more information, see the "Step 1: Enable the Stream feature for the data table" section of the Use Function Compute topic.
Solution 3: Check whether the role of the trigger is correct
Check whether the role that you configured for the trigger is deleted, or whether the role has the required permissions. We recommend that you configure standard roles for triggers.
For OSS triggers, configure the
AliyunOSSEventNotificationRole
role. For more information, see Configure a native OSS trigger.For Tablestore triggers, configure the
AliyunTableStoreStreamNotificationRole
role. For more information, see Step 2: Create a Tablestore trigger.
References
If an object that you upload triggers a function multiple times, you must re-configure the trigger event for your function. For more information, see What do I do if a function is triggered multiple times when an object is uploaded to OSS?