If you have an Alibaba Cloud ECS instance, you can use Cloud Toolkit to quickly deploy applications. This topic describes how to use Cloud Toolkit in Visual Studio Code to deploy an application to an ECS instance.
Prerequisites
You have an ECS instance in the region where you want to deploy your application. For more information, see Purchase an ECS instance.
Note If you purchased your ECS instance before December 1, 2017, you must install the Cloud Assistant client.You have installed and configured Cloud Toolkit in Visual Studio Code. For more information, see Install and configure Cloud Toolkit in Visual Studio Code.
Precautions
Because of limitations in Alibaba Cloud ECS Cloud Assistant, you can only use the root account for this deployment method. To deploy your application using a different account, use one of the following methods:
- Switch accounts in the command script.
- Use the application server feature to deploy. For more information, see Deploy applications to a Linux server.
Procedure
To deploy an application to an ECS instance from Visual Studio Code:
- Open your project in Visual Studio Code.
- Click the Cloud Toolkit icon.
- In the RUN CONFIGURATIONS section, click the
icon and select Deploy to ECS. - On the Deploy ECS View page, set the deployment parameters and click OK.
Parameter descriptions:
- Name: A custom name for the deployment configuration.
- File: Select one of the following options:
- npm build: If your project is built with npm, you can build and deploy it directly.
- Webpack build: If your project is built with Webpack, you can build and deploy it directly.
- Upload file: If you have a local deployment package, select this option to upload it.
- Target ECS: From the drop-down list, select a Region, and then select the target ECS instance.
- Target Directory: The deployment path on the ECS instance. The following code provides example paths:
##Deployment path: /root/tomcat/webapps
##Deployment path: /root/springbootdemo
##Deployment path: /root/go-demo
##Deployment path: /root/nodejs-demo
- Command: The command that runs after the application package is deployed. This is typically a start command. The following code provides an example:
sh /root/restart.shNote For more information about commands, see Command syntax.
Verify the result
After the deployment starts, the deployment log is displayed in the Console section of Visual Studio Code. Check the log to verify the deployment result.