Author: Shekh Muenuddeen
AnyPoint CLI (command line interface) is a powerful tool that can perform many operations in the AnyPoint Platform.
Many on-prem servers do not have direct outside world access. Fortunately, they can be connected to the AnyPoint Platform via AnyPoint CLI.
I am using it to simultaneously deploy one or more applications at the same time by using multiple command prompts.
We can set up AnyPoint installation online and offline. I am going to install it online, but you’ll find the offline installation steps below.
Offiline
https://help.mulesoft.com/s/article/How-to-perform-offline-installation-of-Anypoint-CLI
Steps for Installation
https://docs.mulesoft.com/runtime-manager/anypoint-platform-cli
- Download the Windows Binary (.zip) and Unzip NodeJS and npm (node package manager) on your system.
- Add Unzip Node location to the PATH system variable example “C:\node-v12.16.1-win-x64”.
- Run command to install the anypoint-cli
- npm install -g anypoint-cli@latest
- Once it downloads the anypoint-cli tool you are able to see it.

We have successfully downloaded and installed anypoint-cli, it’s time to login to anypoint platform.
Open command prompt and write below command
anypoint-cli –username “<username>” |

As you can see from the command prompt, I have successfully logged in to my default environment that is Development.
Credentials
There are other ways we can define the default user profile to login every time with default environment.
For this, you need to create “.anypoint” in window User and write file name as “credentials” and define the below parameters.
File name – “credentials”
{
"default": {
"username": "username",
"organization": "organization name",
"environment": "environment name",
"host": ""
},
"otherProfile": {
"username": "",
"password": "",
"organization": "",
"environment": "",
"host": ""
}
}

We can define password here but it’s not a good practice, password will be asked while you login using anypoint-cli command.
You can switch the environment by using the below command.
Use env command Sandbox |

Help Command will give you the commands help which we can perform.

Hints
Type any command runtime-mgr and double tab so that you can get the next possible command or subcommand.

Type the command below to see runtime list.
Cloudhub runtime list |

Hint
Write any command and put help before that, so you will get the possible supported parameter for the same command for example:
help runtime-mgr cloudhub-application deploy |

As you can see that for deploying our application we need to define below parameters:

Using the command line interface you can do the below things:
Runtime-mgr

Account

CloudHub

Use

Exchange

Runtime-mgr

Let’s take one example end to end, as I am going to deploy one application from anypoint cli to cloud hub and I am also going to modify it.
Application Deployment
Command
runtime-mgr cloudhub-application deploy –runtime “<runtime>” –workers “workers” –workerSize “workeSize” –region “region” “application name” “Zip or jar location”
Example
runtime-mgr cloudhub-application deploy –runtime “4.2.2” –workers “1” –workerSize “0.1” –region “us-east-1” “anypoint-cli-dev” “C:/_myWork/mule_workspaces/ebonding/anypoint-cli-dev/target/anypoint-cli-dev-1.0.0-SNAPSHOT-mule-application.jar” |

AnyPoint Platform application deployment done

Application Modification
For modifying my application, I am going to add http.port property.
runtime-mgr cloudhub-application modify –property “http.port:8081” “anypoint-cli-dev” “C:/_myWork/mule_workspaces/ebonding/anypoint-cli-dev/target/anypoint-cli-dev-1.0.0-SNAPSHOT-mule-application.jar” |

As you can see, my application successfully updates the property which I have defined in the command.
You can modify those things which can be done from AnyPoint Platform UI, Use help command to know the support for particular commands.

As you can see the tail logs for deployment
runtime-mgr cloudhub-application tail-logs anypoint-cli-dev |

For more information on the deployment of applications, you can also refer to the article from MuleSoft support below: