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:
| Step | API | Purpose |
|---|---|---|
| 1 | InsertOrUpdateRegion | Create a microservices namespace -- a logical isolation boundary for your services |
| 2 | InsertCluster | Create an ECS cluster -- a resource group that hosts your applications |
| 3 | TransformClusterMember | Import an existing ECS instance into the cluster |
| 4 | InsertApplication | Register the application in EDAS |
| 5 | DeployApplication | Upload 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:
A running ECS instance. For more information, see Create an ECS instance
Alibaba Cloud CLI installed for your operating system:
ossutil installed for uploading deployment packages to OSS
Configure Alibaba Cloud CLI
Run aliyun configure to set your AccessKey pair, default region, and output format.
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| Placeholder | Description |
|---|---|
<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:
| Variable | Description | Example |
|---|---|---|
REGION | Region where the application is deployed | cn-beijing |
ECS_ID | ID of the ECS instance to import | i-2z************b6 |
VPC_ID | Virtual Private Cloud (VPC) ID that the ECS instance belongs to | vpc-t**********c |
NAMESPACE | Name for the microservices namespace (created automatically if it does not exist) | myNamespace |
CLUSTER_NAME | Name for the ECS cluster (created automatically if it does not exist) | myCluster |
APP_NAME | Name for the application | myApp |
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/nullStep 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"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:
| Variable | Description | Example |
|---|---|---|
APP_ID | Application ID from the previous section, or from the EDAS console | 87a6*********************4d1 |
GROUP_ID | Application group ID | 54b*********************f27 |
OSS_BUCKET | Publicly readable OSS bucket for the deployment package | eda*****mo |
PACKAGE | Local path to the WAR or JAR file | hello-edas.war |
APP_ID="87a6*********************4d1"
GROUP_ID="54b*********************f27"
OSS_BUCKET="eda*****mo"
PACKAGE="hello-edas.war"
VERSION=$(date +%s) # Timestamp-based versionStep 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:
Log on to the EDAS console.
In the left-side navigation pane, choose Application Management > Applications, then click the name of your application.
In the upper-right corner of the Basic Information tab, click Deploy.
On the Select Deployment Mode page, click Start Deployment next to Regular Release (Single-batch/Multi-batch).
Click Generate Maven Plug-in Configuration to view the parameter values.

Verify the deployment
After the deployment script finishes, confirm that the application is running:
Log on to the EDAS console.
In the left-side navigation pane, choose Application Management > Applications.
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.
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.