This topic describes how to create a function by using Aliyun Serverless VSCode Extension.
Prerequisites
- You have downloaded the Visual Studio Code (VS Code) component from the official website of Visual Studio Code and installed the component.
- You have installed Docker.
Operations such as code compilation, dependency installation, and local running and debugging are performed in a Docker image.
- You have installed Aliyun Serverless VSCode Extension.
Background information
Provided by Function Compute, Aliyun Serverless VSCode Extension is a VS Code-based development, debugging, and deployment tool that integrates the features of the Funcraft command-line tool and Function Compute SDK. You can use this extension to perform the following operations:
- Quickly initialize projects and create functions locally.
- Run and debug local functions. The debugging feature is supported in three programming languages: Node.js, Python, and PHP.
- Pull services and functions from Function Compute and execute functions in Function Compute.
- Deploy services and functions to Function Compute and update related configurations.
Step 1: Bind an Alibaba Cloud account to the extension
Step 2: Create a function

Step 3: Locally debug the function
- If you want to debug functions that run in Python 2.7 or Python 3 runtimes, you must first install the Python extension.
- If you want to debug functions that run in PHP runtimes, you must first install the PHP Debug extension.
Step 4: Locally call the function
Handler
file to locally call the function.

event.dat
file in the directory that stores the function handler file. You can modify the event.dat
file to configure events that trigger the function when the function is called.
Step 5: Deploy the service and its function
Step 6: Execute the function in Function Compute


Aliyun Serverless VSCode Extension creates an event.dat
file in the root directory of your project. You can modify the event.dat
file to configure events that trigger the function when the function is called in
Function Compute.
Step 7: Test the function in Function Compute
You can log on to the Function Compute console to check whether the preceding deployment is successful.
- Log on to the Function Compute console.
- In the top navigation bar, select a region.
- In the left-side navigation pane, click Service/Function.
- In the Function Compute console, find and click the demo service. On the Functions tab, click the testFunc01 function.
- On the page that appears, click the Code tab. On the Code tab, click Invoke to execute the function in the Function Compute console.
Step 8: View logs of the function
You can view the execution log on the current page after each execution. To view historical execution logs, click the Log tab. You must configure a Logstore for the function first. For more information, see Logs.