This topic describes how to use the command-line interface (CLI) to create and deploy an application based on a deployment package. The Java sample program provided by Web App Service (Web+) is used as an example.


Activate related services and authorize roles

Step 1: Download and install the command-line tool

In Linux or macOS, run the following command to download and install the CLI:

eval "$(curl -s -L"

Step 2: Configure the command-line tool

Run the following command to use the AccessKey ID and AccessKey secret of your account to register and configure the CLI, select the region where the environment resides, and then create a folder, for example, named demo:

wpctl configure --access-key-id "$ALICLOUD_ACCESS_KEY" --access-key-secret "$ALICLOUD_SECRET_KEY" --region "$ALICLOUD_REGION"  --profile demo 
Note For more information about the valid values of the ALICLOUD_REGION parameter, see the Region ID column in Supported regions.

Step 3: Clone the Java sample program

Run the following command to clone the sample program provided by Web+ to the root directory of your project.

If you want to use your own Java program, replace the URL of the sample program in the following command with that of your sample program.

git clone && cd alibabacloud-webplus-demo-java

Step 4: Compile a package and create an application

  1. After cloning the sample program, run the following command to package the sample program:
    mvn package
  2. Run the following command to upload the sample program and create an application and a deployment environment:
    wpctl env:apply --package target/webplus-demo-java*.jar --label webplusVersion0.1 --category Java --env webplusEnvDemo --app webplusAppDemo --create-on-absent
    Note In this step, the application name and deployment environment name are specified. The --create-on-absent flag specifies that Web+ creates an application or deployment environment if the specified application or deployment environment does not exist.

Step 5: Access the application

After the application and deployment environment are created, Web+ purchases the configuration resources in the template for you. It takes about 2 minutes to purchase the resources. Then, you can follow these steps to access the application:

  1. Run the following command to switch to the created application and deployment environment:
    wpctl env:use webplusEnvDemo --app webplusAppDemo
  2. Run the following command to view the event list and verify that the switchover is completed:
    wpctl env:events
  3. Run the following command to view the environment information and obtain the application URL:
    wpctl env:info
  4. Open the application URL and visit the homepage of the application.

Step 6: Release the deployment environment

Run the following command to release the deployment environment.

By default, when the deployment environment is released, the Elastic Compute Service (ECS) instances purchased by Web+ for you are also released and no longer billed. In addition, the purchased Server Load Balancer (SLB) instance is released and no longer billed when no traffic or back-end servers need to be monitored.

wpctl env:terminate --app webplusAppDemo --env webplusEnvDemo
Note Resources in the deployment environment generated by Web+ are billed in Pay-As-You-Go mode. If you still want to keep ECS instances after the deployment environment is released, log on to the ECS console and change the billing method of the created ECS instances to subscription.