In this tutorial, you create an event function that processes OSS upload events, test it using a simulated event, and learn how the event and context handler parameters work — all without needing an OSS bucket.
Prerequisites
How it works
When an event occurs — such as a file upload to Object Storage Service (OSS) or an alert from a monitoring service — a preconfigured trigger invokes your event function automatically. Function Compute provisions instances on demand, scales them as needed, and destroys them after processing. You pay only for the resources consumed.
The scenario this tutorial simulates: files are uploaded as ZIP archives to OSS for transfer efficiency, and an event function decompresses them and saves the output back to OSS.
This tutorial uses a simulated OSS upload event — no actual OSS bucket required. The function parses the event, extracts bucket and file metadata, and prints the results to the Function Compute console.
Step 1: Select the function type
Log on to the Function Compute console. In the left-side navigation pane, click Functions. In the top navigation bar, select a region, such as China (Hangzhou).
Click Create Function.
On the Create Function page, click Event Function. Enter a Function Name or keep the default.

Step 2: Select the runtime
Built-in runtimes include preinstalled dependencies for responding to events from other Alibaba Cloud services. For example, the built-in Python runtime includes oss2 for OSS access, and the built-in Node.js runtime includes ali-oss. Select the runtime for your preferred language:
Python
For Runtime, select Built-in Runtimes > Python > Python 3.10.

If you use a custom runtime or a Custom Container runtime instead, install the required dependencies manually. For a comparison of runtime types, see Function runtime environment selection. For more information about built-in runtime environments, see Overview (Python) or Overview (Node.js).
Node.js
For Runtime, select Built-in Runtimes > Node.js > Node.js 20.

Step 3: Create the function
Use the Hello, world! sample code. Keep the defaults for Advanced Settings and Environment Variables, then click Create.

After creation, WebIDE opens on the Code tab and shows the generated handler template. You'll replace this template with the event-processing code in the next step.

Step 4: Deploy the event-processing code
Interpreted languages like Python and Node.js support editing and deploying code directly in WebIDE. Compiled languages like Java require local compilation and package upload.
Python
Open index.py in WebIDE, replace the existing code with the following, and click Deploy.
Node.js
Open index.mjs in WebIDE, replace the existing code with the following, and click Deploy.
About the handler parameters (optional)
The handler is the entry point for all function executions. Keep the handler name unchanged so Function Compute can locate it correctly.
`event`
Carries event-related data when a trigger invokes the function — for example, the bucket name and file name in an OSS upload event. The parameter is a JSON object. For the exact structure per trigger type, see Formats of event for different triggers.
`context`
Carries function invocation details, configuration, and authentication credentials. Function Compute calls the AssumeRole operation to get a Security Token Service (STS) token based on the role assigned to your function, then passes it via the credentials field in the context object. For the complete context structure, see Context (Python) or Context (Node.js).
Logging
Use the standard logging library for your runtime to write logs during execution. This sample logs the bucket name, file name, and region. View logs on the Log Output tab after the function runs.
Python:
loggingmodule,logger.info(). For details, see Logs.Node.js:
consolemodule,console.log(). For details, see Logs.
For more information, see What is a handler? (Python) or What is a handler? (Node.js).
Step 5: Test the function
The following steps use a simulated OSS event, which doesn't require an actual OSS bucket. To test with real OSS events instead, see Advanced operations.
On the Function Details page, click the Code tab. Click the drop-down icon next to Test Function and select Configure Test Parameters.
In the Configure Test Parameters panel, select OSS from the Event Template drop-down list. A simulated event is generated in the same JSON format as a real OSS event. Optionally, set an Event Name and customize field values such as the bucket name and file name. Click OK.

Click Test Function. Function Compute passes the simulated event to the handler via the
eventparameter and runs the deployed code.After execution, check the Response tab. A return value of
0indicates successful processing. Click Log Output to review the log entries generated during execution.
Step 6: (Optional) Clean up resources
Function Compute charges only when functions are invoked, so idle functions don't incur costs. If you no longer need the function, delete it to avoid charges from other resources it may reference (such as data in OSS or File Storage NAS (NAS)).
To delete the function, log on to the Function Compute console. In the left-side navigation pane, click Functions and select a region. Find the function, click the vertical ellipsis icon in the Actions column, and select Delete. Confirm that the function is not bound to any resources, then click Delete.

Advanced operations
You've created an event function, deployed event-processing code, and tested it with a simulated event. For production use cases, consider the following:
Add a trigger: The demo above used a simulated event. To process real OSS upload events, add an OSS trigger to your function. For details, see Configure a native OSS trigger. Function Compute also supports triggers from message queue services, Tablestore, Simple Log Service, and other Alibaba Cloud services. For all supported types, see Trigger overview.
Add dependencies: Each built-in runtime includes common event-processing libraries, but your use case may require additional ones. Package your code and extra dependencies into a ZIP file and deploy it to Function Compute. For steps, see Deploy a code package. To reduce package size and mitigate cold starts, manage shared dependencies as layers. For details, see Create a custom layer.
Configure logging: Set up the logging feature to simplify debugging, troubleshooting, and security auditing. For steps, see Configure the logging feature.
What's next
To create functions using CLI tooling instead of the console, see Serverless Devs quick start.
For a hands-on example of event-driven processing, see Use Function Compute to perform message cleansing.
For an overview of all trigger types, see Trigger overview.
References
In addition to using the console, you can also use the Serverless Devs command line interface to perform these operations. For more information, see Quick Start.
See the following tutorials to learn more about event functions: