AnyPoint CLI
- April 22, 2020
The AnyPoint command line interface (CLI) is a powerful tool that can perform many operations in the AnyPoint Platform.
Many on-premises servers do not have direct outside-world access. Fortunately, these servers can be connected to the AnyPoint Platform via AnyPoint CLI. For example, you can use CLI to simultaneously deploy one or more applications using multiple command prompts.
AnyPoint can be installed both offline and online, as described below:
- Download the Windows Binary (.zip), as well as Unzip NodeJS and the node package manager (npm) on your system
- Add the Unzip Node location to the PATH system variable — for example, C:\node-v12.16.1-win-x64
- Run the command to install the Anypoint CLI:
npm install -g anypoint-cli@latest
You’ll see the tool once it downloads
- Once you’ve successfully downloaded and installed Anypoint CLI, log in to your Anypoint Platform
- Open a command prompt and write below command:
anypoint-cli –username “<username>”
As you’ll see from the command prompt, you’ve successfully logged in to your default Development environment.
Credentials
There are other ways to define the default user profile so it logs in with your default environment every time. For this, you need to create “.anypoint” in the User window, write the filename as “credentials” and define the following parameters:
File name – “credentials”
{
"default": {
"username": "username",
"organization": "organization name",
"environment": "environment name",
"host": ""
},
"otherProfile": {
"username": "",
"password": "",
"organization": "",
"environment": "",
"host": ""
}
}
You can define the password here, but it’s not a good practice because you’ll be asked for the password when you log in using the Anypoint CLI command.
Switch the environment by using the following command:
Use env command Sandbox |
The Help command will give you the commands to perform.
Hints:
- Type any command runtime-mgr and double tab to get the next possible command or subcommand.
- Type the following command to see runtime list:
Cloudhub runtime list
Hint: Write any command and put “help” before that so you’ll 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, deploying one application from Anypoint CLI to CloudHub and 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
To modify this application, we’ll 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, the application successfully updates the property defined in the command.
You can modify anything that can be modified from the AnyPoint Platform UI. Use the help command to find specific commands.
Here are the tail logs for deployment:
runtime-mgr cloudhub-application tail-logs anypoint-cli-dev |
For more information on application deployment, refer to this MuleSoft support article.
— By Shekh Muenuddeen