Edge Security Acceleration (ESA) provides a CLI tool for you to manage and debug Edge Routines throughout their lifecycle and deploy multi-file projects.
What is ESA CLI
The ESA CLI is a command line tool of ESA Edge Routine. You can complete the following jobs by using the ESA CLI tool.
Manage the full lifecycle of Edge Routines locally, such as routine creation, version release and deployment, as well as trigger management.
Debug routines locally or in an intranet environment with a local debugging service to simulate the online environment for functional testing.
Deploy multi-file projects by automatically packaging and building project dependencies, such as npm, to deploy local Node.js projects to the cloud.
Before you begin
Before you use ESA CLI, you must install Node.js.
Run the
yum install nodejs npm
command to install Node.js and npm.Run the
node -v
command to view the version.
Get started with ESA CLI
Use npm to install the ESA CLI tool, and check the CLI version and supported commands.
npm install esa-cli -g # Install the CLI globally.
esa -v # View the CLI version.
esa --help # View the CLI command.
Log in to your account. Log on to the Alibaba Cloud RAM console to obtain your
AccessKey Secret
andAccessKey ID
. Then, run theesa login
command to complete the logon process. If you only debug code locally by using the ESA CLI tool, you do not need to log in to your account.
esa login # Login
esa logout # Log out
Initialize a project. This includes project name input and template selection. The entire process can be completed based on the guidance of the initialization command.
esa init
Local debugging. After you complete a coding task, you can debug it locally by using the ESA CLI tool. After you run the
esa dev
command, the entry file is automatically packaged, and the local debugging service is started.Press
b
to open the debugging page in the browser.Press
d
to view the debugging wizard. Note: Chrome does not allow the debugging page to be opened from the command line. Open thechrome://inspect#devices
page in Chrome to see a runningRemote Target
. Clickinspect
to view the information of the console. Note that Edge Routine operates on the server side, which indicates thatconsole
logs from the entry file are not displayed in the console of the preview page. You can only use theinspect
feature to debug.Press
c
to clear the console.Press
x
to exit debugging.Temporarily specify a port by running the
esa dev --port <port>
command.
Version generation. After you complete debugging locally, you must generate a version of the code for deployment.
esa commit # Generate a version.
Online deployment. After the version is generated, use the deployment commands to deploy the code to the POPs in Alibaba Cloud.
esa deploy # Select the version and target environment to deploy.
esa deployments list # View the deployment status.
esa deployments delete <versionId> # Delete a version.
Manage a trigger
After the code is deployed to an ESA POP, you can configure a trigger and invoke an edge routine by using that trigger. Edge Routine supports two trigger methods:
Domain name: Associate the domain name of your website with the routine. This domain must be a subdomain of your ESA site, so you can use the domain name to access the routine. The edge routine serves as the origin for that domain.
Route: Create a route to map the request URLs of an ESA site to a routine. The routine is invoked if a request matches the route, enabling the edge routine to communicate with the origin server.
# Domain Name
esa domain list
esa domain add <domainName> # The domain name must be filed for Internet Content Provider (ICP).
esa domain delete <domainName>
# Route
esa route list
esa route add [route] [site]
esa route delete <route>
Manage a routine.
Use the ESA CLI tool to view and delete a routine.
esa routine list # Show a list of the routines.
esa routine delete <RoutineName> # Deletes a routine.
Common commands
The ESA CLI provides commands to manage Edge Routines. The following shows some common command parameters.
init
Initiates a project. Select a template provided by ESA to complete project initialization.
dev
Automatically enable the local debugging service.
commit
Submit the project code. Submit the project code to the cloud where you can save it as a version.
deploy
Deploy a version. Deploy a specific version to all online ESA points of presence (POPs).
deployments
View the deployment status of the current version or delete a specific version.
routine
View all Edge Routines or delete a specific routine.
site
View the information about all the websites under your account.
domain
Manage domain names associated with Edge Routines.
route
Manage routes associated with Edge Routines.
login
Log on to the account by using Access Key (AK) or Secret Key (SK).
logout
Log off.
config
Manage configuration files of ESA CLI.
lang
Select the language of ESA CLI.