This topic describes how to use Aliyun Serverless VSCode Extension to create a template.
Aliyun Serverless VSCode Extension provides syntax prompts for ROS template files. It also allows you to develop and debug Function Compute functions on your local PC. For more information, see serverless-vscode. You must install Visual Studio Code to use Aliyun Serverless VSCode Extension.
- Automatic completion: Resource property configurations in a template file are completed automatically according to prompts provided based on the indentation level.
- Schema validation: All resource configurations in a template file are validated based on the specifications in Serverless Application Model.
- Hovering prompts: Context-sensitive help is provided for all resource configurations in a template file. When you move the pointer over a resource key, property information such as the property name, type, and document URL is displayed.
Step 1: Install the extension
- Open VS Code and press
Ctrl+Shift+Xto go to the extension marketplace.
- Search for Aliyun Serverless and install it.
- Restart VS Code.
When the ALIYUN:FUNCTION COMPUTE icon is displayed in the left-side activity bar, the extension is installed.
Step 2: Bind an Alibaba Cloud account
- Start ALIYUN:FUNCTION COMPUTE.
- Click Bind New Account under the REMOTE RESOURCES option. In the text box that appears, enter the account ID, AccessKey ID, AccessKey
secret, and local name of the account in sequence.
After you enter the information, the name and region appear in the lower-left corner, which indicates that the account is bound.
Step 3: Create a template
- Open a folder in VS Code, and Aliyun Serverless VSCode Extension is still in the inactive
state. Click the
ALIYUN:FUNCTION COMPUTEicon to activate it.
- Create a template.yml file.
rosin the first line, and press the Enter key twice. The system prompts you for the required parameters.
- Enter keywords of a resource type under
Resources, and then a list of related resources is provided.
For example, if you enter
ECS, all resources related to ECS appear. After you select a resource type, a schema is generated. When you move the pointer over
Properties, all properties and data types of the resource type appear.Note You can search for the names of properties by fuzzy match. When required properties are missing, alerts are triggered for
Properties, and prompts appear in the console.