Without triggers, you must invoke a Function Compute function manually—through the console, SDK, or API—every time you need it to respond to an external event. Triggers automate this: when an event from a connected service matches the rules you define, the event source invokes the function automatically. This lets you build event-driven workflows without writing polling or scheduling logic.
How triggers work
Function Compute uses an event-driven model: an event source acts as the producer, and a function acts as the processor. Each trigger holds a set of matching rules. When an incoming event satisfies those rules, the event source invokes the associated function.
You can still invoke a function directly through the Function Compute console, the SDK, or the API. Triggers serve a distinct purpose: hands-off, automatic invocation driven by events in other Alibaba Cloud services or external systems.
A single trigger invokes only one function. To fan out one trigger to multiple functions, use Function Compute with CloudFlow. Configure the triggered function to start a CloudFlow workflow, then invoke additional functions from within that workflow. See the demo for a working example.
Use cases
| Scenario | Trigger to use | What happens |
|---|---|---|
| Process images as they are uploaded to OSS | OSS trigger | Detects new uploads and invokes the function to download, process, and store the result |
| Analyze logs as they arrive in Simple Log Service | Simple Log Service trigger | Detects log updates and invokes the function to consume incremental log data |
| Run a task on a fixed schedule (for example, collect data every hour) | Time trigger | Fires the function at the specified interval automatically |
Invocation methods
Each trigger invokes functions either synchronously or asynchronously.
-
Synchronous invocation: The result is returned after the function finishes processing the event. Invoking a function from the Function Compute console is an example of synchronous invocation.
-
Asynchronous invocation: The result is returned after the event is written to Function Compute's internal queue. Function Compute then processes the event reliably in the background.
For details, see Synchronous invocations.
Trigger types
Triggers are grouped by how they integrate with event sources.
Two-way integrated triggers
Configure these triggers in both Function Compute and the event source service.
| Trigger | Invocation method | References | |
|---|---|---|---|
| HTTP triggers | Synchronous and asynchronous | Overview | |
| Time triggers | Asynchronous | Time triggers | |
| OSS triggers | Asynchronous | Overview of OSS event triggers | |
| Simple Log Service triggers | Synchronous | Simple Log Service triggers | |
| Alibaba Cloud CDN triggers | Synchronous | Overview of Alibaba Cloud CDN event triggers | |
| Tablestore triggers | Synchronous | Tablestore triggers | |
| Simple Message Queue (formerly MNS) topic triggers | Asynchronous | Simple Message Queue (formerly MNS) topic triggers | |
|
EventBridge-based triggers |
Simple Message Queue (formerly MNS) queue triggers (EventBridge-based) | Synchronous and asynchronous | Overview of Simple Message Queue (formerly MNS) queue triggers |
| ApsaraMQ for RocketMQ / Self-managed Apache RocketMQ triggers | Synchronous and asynchronous | ApsaraMQ for RocketMQ triggers | |
| ApsaraMQ for RabbitMQ triggers | Synchronous and asynchronous | ApsaraMQ for RabbitMQ triggers | |
| ApsaraMQ for Kafka triggers | Synchronous and asynchronous | ApsaraMQ for Kafka triggers | |
| ApsaraMQ for MQTT triggers | Synchronous and asynchronous | ApsaraMQ for MQTT triggers | |
| Data Transmission Service (DTS) triggers | Synchronous and asynchronous | DTS triggers | |
One-way integrated triggers
Configure these triggers only in Function Compute, not in the event source.
| Trigger | Invocation method | References |
|---|---|---|
| API Gateway triggers | Synchronous | API Gateway triggers and Cloud-native API Gateway triggers |
| ALB triggers | Synchronous and asynchronous | ALB triggers |
Event triggers for Alibaba Cloud services
Configure these triggers in Function Compute and EventBridge. No configuration is needed in the event source service itself.
| Trigger | Invocation method | References |
|---|---|---|
| Event triggers for Alibaba Cloud services | Synchronous and asynchronous | Configure event triggers for Alibaba Cloud services |