This topic describes how to activate and use Edge Routine in the Edge Security Acceleration (ESA) console.
Before you begin
Your website has been added to ESA and is in the Active state. Refer to Add your website to ESA by NS setup or Add your website to ESA by CNAME setup to add a website.
An SSL/TLS certificate is configured for the website before you access Edge Routine over HTTPS.
Step 1: Create a routine
Log on to the ESA console, and in the left-side navigation pane, choose .
On the Edge Routine page, click Create Routine.
On the Create Routine page, select a template provided by ESA to generate routine code. You can also select a template for a custom routine. Click Next.
On the page that appears, configure parameters including Routine Name and click OK.
The following list shows the parameters:
Routine Name
Enter a routine name.
NoteThe name must be 2 to 41 characters and can include lowercase letters, digits, and hyphens (-). It must start with a lowercase letter and cannot end with a hyphen. For example: routine-name. Once created, the routine name cannot be changed.
Description
Optional. Enter a description for the routine.
Code Preview
Preview the routine code.
Step 2: Configure a trigger
Edge Routine of ESA allows you to use triggers to define the calling methods of scripts. You can associate a domain such as er.example.com
with a routine. This way, all the traffic destined for the domain is directed to the routine. You can also add a route to specify matching URLs in a routine. In this case, a portion of the traffic destined for the specified URLs is directed to the routine. For example, if you add the er.example.com/test/path/
route in a routine, the traffic to er.example.com/test/path/ is directed to the routine.
Upon creation of the Edge Routine, click Associate Domain Name.
On the Triggers page. You can associate a domain name or add a route to direct traffic destined for a specific domain to the routine.
Step 3: Develop and debug a routine
On the Edge Routine details page, click the Code tab and develop the routine by using
JavaScript (ES6 syntax)
.Debug the routine code. ESA provides a debugging environment. After you compile the code, you can click Save on the Code tab. Then, you can construct an HTTP request method, header, and body on the right side of the Code tab and click Request. ESA directly returns a response after the routine processes the request.
After you debug the code, click Generate Version. On the Deploy tab, view the generated version.
Click Release in the Actions column, in the dialog that appears, set the Deployment Environment parameter to Staging Environment. The code takes effect on the test POP. You can add a binding entry to your
local hosts
file. This allows you to initiate a request from a real client and view the response on the client.NoteWe recommend that you deploy the version to all the canary environments before you deploy the version to the production environments.
Step 4: Release the official version
On the Edge Routine details page, click the Deploy tab. Click Release in the Actions column of the desired version.
In the dialog that appears, set the Deployment Environment parameter to Production Environment.
Click Release. Then, code of this version is deployed to all POPs of the production environments.