Use the Alibaba Cloud CLI extension for VS Code
Install and use the Alibaba Cloud CLI extension for Visual Studio Code (VS Code) to call API operations from the editor. This example calls the DescribeInstances operation of Elastic Compute Service.
Prerequisites
-
Alibaba Cloud CLI is installed and configured with a profile. Use Alibaba Cloud CLI to call API operations.
-
The
AliyunECSReadOnlyAccesspermission is granted to your RAM user.ECS
Overview
To call the DescribeInstances operation of ECS by using the extension:
-
Install the
Alibaba Cloud CLI Toolsextension. -
Create an
.aliyunfile and write theDescribeInstancescommand. -
Run the command in the editor or terminal.
Step 1: Install the Alibaba Cloud CLI extension
Install the extension from the marketplace
-
In the VS Code activity bar, click the
icon. -
Search for
Alibaba Cloud CLI Tools, select it from the results, and click Install.
Install the extension from a browser
-
Open Alibaba Cloud CLI Tools in the VS Code Marketplace and click Install. VS Code opens the extension page.
-
Click Install.
After installation, the extension icon and current profile appear in the status bar. Click the icon to change the profile.
Step 2: Write a command
-
Choose File > New File and name the file
example.aliyun.NoteThe extension provides auto-completion for commands, methods, and parameters in
.aliyunfiles.Auto completion for commands

Auto completion for methods

Auto completion for parameters

-
Write the following command and specify parameters as needed.
aliyun ecs DescribeInstances --InstanceIds "['i-bp118piqciobxjkb****']"
Step 3: Run the command
You can run commands on the terminal or in the editor.
Run the complete command on the terminal
Click run above the command to run it in the terminal.

Run the selected part of the command on the terminal
-
Select the part of the command to run, then right-click it.
-
Choose Alibaba Cloud CLI > Run Line in Terminal.

Run the selected part of the command in the editor
-
Select the part of the command to run, then right-click it.
-
Choose Alibaba Cloud CLI > Run Line in Editor.

