Function Compute provides two function types: event functions and HTTP functions. Your choice determines the handler signature and how your function is triggered, so pick the right type before writing code.
A handler consists of three parts: the function name, the function input parameters, and responses. You can also pass another function defined in the code as an input parameter to the handler.
How the types differ
| Feature | Event functions | HTTP functions |
|---|---|---|
| Trigger method | Timers, API/SDK calls, and triggers from other Alibaba Cloud services (OSS, Log Service, Alibaba Cloud CDN, Tablestore, EventBridge, and more) | HTTP or HTTPS requests only |
| Supported triggers | All trigger types | HTTP triggers only (one per version or alias) |
| Handler parameters | event, context, callback | request, response, context |
| Best for | Event-driven pipelines and integrations | Web applications and APIs |
Event functions
An event function runs in response to an event from a timer, an API or SDK call, or a trigger from another Alibaba Cloud service. All supported trigger types work with event functions.
Use when you need to:
Process files after they are uploaded to Object Storage Service (OSS)
Run scheduled jobs with a timer trigger
React to log entries, CDN events, or messages from EventBridge
Handle any event-driven workflow that does not require direct HTTP access
Handler signature (Node.js):
exports.handler = function(event, context, callback) {
callback(null, 'hello world');
}| Parameter | Description |
|---|---|
event | The event data passed to the handler. Convert it to the appropriate type based on your business requirements. |
context | Runtime information provided by Function Compute, including request IDs and temporary keys. |
callback | The function to call when returning invocation results. |
For Node.js event function details, see Event handlers. For other programming languages, see Programming model overview.
HTTP functions
An HTTP function is triggered exclusively by HTTP or HTTPS requests. It accepts standard HTTP request methods (GET, POST, PUT, DELETE, HEAD, PATCH) and gives you direct access to the request and response objects — no intermediate event format conversion needed.
Each version or alias of a service supports only one HTTP trigger.
Use when you need to:
Build RESTful APIs or web backends
Migrate an existing web framework (Express, Koa, or similar) to the cloud
Handle HTTP requests directly without going through an event format layer
Handler signature (Node.js):
exports.handler = function(request, response, context) {
response.send(null, 'hello world');
}| Parameter | Description |
|---|---|
request | The HTTP request, including headers (key-value pairs), the request method, and the client IP address. |
response | The HTTP response, including headers (key-value pairs) and the response body. |
context | Runtime information provided by Function Compute, including request IDs and temporary keys. |
For Node.js HTTP function details, see HTTP handlers. For other programming languages, see Programming model overview.
What's next
Explore all available trigger types: Trigger overview
Set up an HTTP trigger: HTTP trigger overview
Review programming model details for all runtimes: Programming model overview