All Products
Search
Document Center

Enterprise Distributed Application Service:Deploy an application to an ECS cluster by using Alibaba Cloud CLI

Last Updated:Mar 11, 2026

When you need to automate application deployments to Enterprise Distributed Application Service (EDAS) -- for example, from a CI/CD pipeline or a provisioning script -- Alibaba Cloud CLI lets you create namespaces, clusters, and applications, then deploy WAR or JAR packages, all without leaving the terminal.

EDAS supports Spring Cloud, Dubbo, and High-speed Service Framework (HSF) applications through its SDKs and API.

Workflow overview

Deploying an application to an Elastic Compute Service (ECS) cluster involves the following primary API operations:

StepAPIPurpose
1InsertOrUpdateRegionCreate a microservices namespace -- a logical isolation boundary for your services
2InsertClusterCreate an ECS cluster -- a resource group that hosts your applications
3TransformClusterMemberImport an existing ECS instance into the cluster
4InsertApplicationRegister the application in EDAS
5DeployApplicationUpload a WAR or JAR package to Object Storage Service (OSS) and trigger a deployment

The following sections walk through each step.

Prerequisites

Before you begin, make sure that you have:

Configure Alibaba Cloud CLI

Run aliyun configure to set your AccessKey pair, default region, and output format.

Note Create or view your AccessKey pair on the Security Management page of the User Management console. Contact your administrator if you do not have one.
aliyun configure
Configuring profile 'default' ...
Aliyun Access Key ID [None]: <your-access-key-id>
Aliyun Access Key Secret [None]: <your-access-key-secret>
Default Region Id [None]: cn-hangzhou
Default output format [json]: json
Default Language [zh]: zh
PlaceholderDescription
<your-access-key-id>Your AccessKey ID
<your-access-key-secret>Your AccessKey secret

After the configuration completes, the CLI displays a Configure Done!!! banner.

Create an application in an ECS cluster

The following steps cover the first four API calls from the workflow overview: creating a namespace, creating a cluster, importing an ECS instance, and registering an application.

Before running the commands, replace the placeholder variables with your actual values:

VariableDescriptionExample
REGIONRegion where the application is deployedcn-beijing
ECS_IDID of the ECS instance to importi-2z************b6
VPC_IDVirtual Private Cloud (VPC) ID that the ECS instance belongs tovpc-t**********c
NAMESPACEName for the microservices namespace (created automatically if it does not exist)myNamespace
CLUSTER_NAMEName for the ECS cluster (created automatically if it does not exist)myCluster
APP_NAMEName for the applicationmyApp

Set the variables

REGION="cn-beijing"
ECS_ID="i-2z************b6"
VPC_ID="vpc-t**********c"
NAMESPACE="myNamespace"
CLUSTER_NAME="myCluster"
APP_NAME="myApp"

Step 1: Create a microservices namespace

Create the namespace with the tag <region>:<namespace>:

aliyun edas InsertOrUpdateRegion \
  --RegionTag "$REGION:$NAMESPACE" \
  --RegionName "$NAMESPACE" \
  --region "$REGION" \
  --endpoint "edas.cn-beijing.aliyuncs.com" >> /dev/null

Step 2: Create an ECS cluster

Create a VPC-mode ECS cluster (ClusterType 2, NetworkMode 2) and capture the cluster ID:

CLUSTER_ID=$(aliyun edas InsertCluster \
  --ClusterName "$CLUSTER_NAME" \
  --ClusterType 2 \
  --NetworkMode 2 \
  --VpcId "$VPC_ID" \
  --logicalRegionId "$REGION:$NAMESPACE" \
  --region "$REGION" \
  --endpoint "edas.cn-beijing.aliyuncs.com" \
  | sed -E 's/.*"ClusterId":"([a-z0-9-]*)".*/\1/g')

echo "Cluster ID: $CLUSTER_ID"

Step 3: Import the ECS instance

Import the ECS instance into the cluster. The script polls ListClusterMembers for up to 300 seconds until the instance reports its ECU ID:

aliyun edas TransformClusterMember \
  --InstanceIds "$ECS_ID" \
  --TargetClusterId "$CLUSTER_ID" \
  --Password Hello1234 >> /dev/null

for i in $(seq 300); do
  OUT=$(aliyun edas ListClusterMembers --ClusterId "$CLUSTER_ID" | grep EcuId) && break
  sleep 1
done
ECU_ID=$(echo "$OUT" | sed -E 's/.*"EcuId":"([a-z0-9-]*)".*/\1/g')

echo "ECU ID: $ECU_ID"
Note The import process can take several minutes. The loop checks once per second for up to 5 minutes.

Step 4: Create the application

Register the application with BuildPackId 51 and the ECU from Step 3:

APP_ID=$(aliyun edas InsertApplication \
  --ApplicationName "$APP_NAME" \
  --BuildPackId 51 \
  --EcuInfo "$ECU_ID" \
  --ClusterId "$CLUSTER_ID" \
  --logicalRegionId "$REGION:$NAMESPACE" \
  | sed -E 's/.*"AppId":"([a-z0-9-]*)".*/\1/g')

echo "Application created. App ID: $APP_ID"

Save the APP_ID value for the deployment step.

Deploy the application

After the application is created, deploy a WAR or JAR package. The following steps upload the package to an OSS bucket, submit an asynchronous deployment request, and poll until the deployment completes.

Variables

Replace the following variables with your actual values:

VariableDescriptionExample
APP_IDApplication ID from the previous section, or from the EDAS console87a6*********************4d1
GROUP_IDApplication group ID54b*********************f27
OSS_BUCKETPublicly readable OSS bucket for the deployment packageeda*****mo
PACKAGELocal path to the WAR or JAR filehello-edas.war
APP_ID="87a6*********************4d1"
GROUP_ID="54b*********************f27"
OSS_BUCKET="eda*****mo"
PACKAGE="hello-edas.war"
VERSION=$(date +%s)    # Timestamp-based version

Step 1: Upload the deployment package to OSS

ossutil cp -f "$PACKAGE" "oss://$OSS_BUCKET/$PACKAGE" >> /dev/null
PKG_URL=$(ossutil sign "oss://$OSS_BUCKET/$PACKAGE" | head -1)

echo "Package URL: $PKG_URL"

Step 2: Trigger the deployment

CO_ID=$(aliyun edas DeployApplication \
  --AppId "$APP_ID" \
  --PackageVersion "$VERSION" \
  --DeployType url \
  --WarUrl "$PKG_URL" \
  --GroupId "$GROUP_ID" \
  | grep '.*"ChangeOrderId":' \
  | sed -E 's/.*"ChangeOrderId":\s"([a-z0-9-]*)".*/\1/g')

echo "Change order ID: $CO_ID"

Step 3: Wait for the deployment to complete

The script polls GetChangeOrderInfo for up to 300 seconds. A PipelineStatus value of 2 indicates success:

for i in $(seq 300); do
  STATUS=$(aliyun edas GetChangeOrderInfo --ChangeOrderId "$CO_ID" \
    | grep '.*"PipelineStatus":' \
    | sed -E 's/.*"PipelineStatus":\s(.).*/\1/g')
  [[ 2 = ${STATUS} ]] && break
  sleep 1
done

echo "Deployment complete. Change order ID: $CO_ID"

Find APP_ID and GROUP_ID in the console

If you do not have these values from the creation step, retrieve them from the EDAS console:

  1. Log on to the EDAS console.

  2. In the left-side navigation pane, choose Application Management > Applications, then click the name of your application.

  3. In the upper-right corner of the Basic Information tab, click Deploy.

  4. On the Select Deployment Mode page, click Start Deployment next to Regular Release (Single-batch/Multi-batch).

  5. Click Generate Maven Plug-in Configuration to view the parameter values.

Generate Maven Plug-in Configuration

Verify the deployment

After the deployment script finishes, confirm that the application is running:

  1. Log on to the EDAS console.

  2. In the left-side navigation pane, choose Application Management > Applications.

  3. Click the name of the deployed application, then click the Instance Information tab next to Basic Information.

The deployment is successful when the instance status shows Normal.

Note If the deployment fails, see Error codes that may be returned in a change process for troubleshooting.

See also

EDAS developer tools community

If you have questions or suggestions about using developer tools in EDAS, you can join the DingTalk group by searching for the ID 34556175 in DingTalk.