Use the Alibaba Cloud CLI extension for VS Code

更新时间:
复制 MD 格式

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

  1. Alibaba Cloud CLI is installed and configured with a profile. Use Alibaba Cloud CLI to call API operations.

  2. The AliyunECSReadOnlyAccess permission is granted to your RAM user.ECS

Overview

To call the DescribeInstances operation of ECS by using the extension:

  1. Install the Alibaba Cloud CLI Tools extension.

  2. Create an .aliyun file and write the DescribeInstances command.

  3. Run the command in the editor or terminal.

Step 1: Install the Alibaba Cloud CLI extension

Install the extension from the marketplace

  1. In the VS Code activity bar, click the image icon.

  2. Search for Alibaba Cloud CLI Tools, select it from the results, and click Install.

Install the extension from a browser

  1. Open Alibaba Cloud CLI Tools in the VS Code Marketplace and click Install. VS Code opens the extension page.

  2. 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

  1. Choose File > New File and name the file example.aliyun.

    Note

    The extension provides auto-completion for commands, methods, and parameters in .aliyun files.

    Auto completion for commands

    image

    Auto completion for methods

    image

    Auto completion for parameters

    image

  2. 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.

image

Run the selected part of the command on the terminal

  1. Select the part of the command to run, then right-click it.

  2. Choose Alibaba Cloud CLI > Run Line in Terminal.

    image

Run the selected part of the command in the editor

  1. Select the part of the command to run, then right-click it.

  2. Choose Alibaba Cloud CLI > Run Line in Editor.

image