Deploy an application to a remote server using Visual Studio Code

更新时间:
复制 MD 格式

Cloud Toolkit supports deploying applications to servers that use the standard Secure Shell (SSH) protocol. You do not need to switch between multiple Operations and Maintenance (O&M) tools. You can simply select the target server in the graphical interface to quickly deploy your application.

Prerequisites

Deploy an application to a remote server

You can deploy a local application by following these steps:

  1. Import your local application into Visual Studio Code.

  2. Add a server.

    1. In the menu bar on the left, click the Alibaba Cloud icon. Then, in the ALIBABA CLOUD TOOLKIT sidebar, choose ALIBABA CLOUD VIEW > Host View.

    2. On the Host tab that appears, click Add Host.

    3. In the Add Host dialog box, set the Host List, Port, and SSH Profile parameters. Then, click Test Connection to verify the server connection.

  3. Deploy the application.

    1. In the ALIBABA CLOUD TOOLKIT sidebar, click the ... icon next to RUN CONFIGURATIONS and choose Deploy to Host.

    2. On the Deploy to Host tab, set the deployment parameters and then click Apply.

      • Deployment (Required):

        The following table describes the deployment parameters.

        Parameter

        Description

        Name

        A name for the configuration. This helps distinguish it from other configurations.

        File

        Select a packaging method: npm build, Webpack build, or Upload file.

        Project

        Select the root directory of the project to be deployed. This parameter is required when you set the packaging method to npm build or Webpack build.

        Build Output

        The output directory after packaging. This parameter is required when you set the packaging method to npm build or Webpack build.

        Scripts

        Select a script command. This parameter is required only when you set the packaging method to npm build.

        Webpack

        The Webpack configuration. Select a Webpack script. This parameter is required only when you set the packaging method to Webpack build.

        File

        Select the folder of the file to upload. This parameter is required only when you set the packaging method to Upload file.

        Target Host

        The remote target server for this deployment.

        Target Directory

        The specified deployment directory on the remote target server.

        After deploy

        Enter the application start command. This command is executed after the application package is deployed.

        For example, for a Java program, this is usually a Tomcat start command, such as sh /root/restart.sh.

      • Advanced (Optional): Configure the start command and the post-deployment command. When you are finished, click Apply.

Verify the result

After the deployment starts, deployment logs appear in the Console area of Visual Studio Code. Check the log information to verify the deployment result.

You can also log on to the remote server using the built-in terminal. Run the cd command to go to the deployment path. Then, run the ls command to check if the deployment was successful. To log on to the remote server, follow these steps:

  1. In the menu bar on the left, click the Alibaba Cloud icon. Then, in the ALIBABA CLOUD TOOLKIT sidebar, choose ALIBABA CLOUD VIEW > Host View.

  2. On the Host View tab, find the target remote server and click Terminal in the Actions column to log on to the remote server.