Clone an Application or a Firewall
Copy an Application with its cache settings, Function Instances, and rules, or a Firewall with its Function Instances and rules, with one API v4 request.
You can clone an Application or a Firewall with one POST request to the Azion API v4. To clone an Application from Azion Console instead, refer to Clone an application. To clone one with the Azion CLI, refer to Azion CLI clone. In Azion Console, the Clone row action of the Firewalls list clones a Firewall.
The examples clone an Application that holds a cache setting, a Function Instance, two request rules, and a response rule. They also clone a Firewall that holds a Function Instance and two request rules.
Prerequisites
- A personal token. To create one, refer to Manage personal tokens.
curl, to call the API, andjq, to read IDs from the responses.- The ID of the Application or the Firewall to clone.
Clone an Application
The clone endpoint takes one required field, name: 1 to 100 characters that no other Application uses.
To clone the Application:
-
Store your token and the ID of the Application in shell variables. Replace the two values with your own:
Shell -
Send a
POSTrequest to the clone endpoint of the Application. Replaceshop-productionwith the name of your copy:ShellThe API answers
202, and the response carries the new Application. This excerpt shows its ID and name:JSON -
Store the ID of the copy:
The account holds a new Application named shop-production, and CLONE_ID holds its ID.
A name that another Application already uses returns 400 with code 31000 and the title Name Already In Use. A body without name returns 400 with code 10059.
A request reaches the copy only once the deployment of a Workload sets that Application. To set it, refer to Deployment.
Check what the Application clone carries
The copy carries the cache settings, the Function Instances, and the request and response rules of the original, each with a new ID. The request rules of the copy point at the cache settings and Function Instances of the copy, not at those of the original.
To check the copy:
-
Store your token and the ID of the copy. Replace the two values with your own:
Shell -
List the cache settings of the copy:
ShellThe copy holds one cache setting,
static-assets, under a new ID:JSON -
List the Function Instances of the copy:
ShellThe copy holds one Function Instance,
hello, which runs the same Function as the original:JSON -
List the request rules of the copy, with their behaviors:
ShellEach request rule of the copy points at the cache setting or the Function Instance of the copy:
JSON -
List the response rules of the copy:
ShellThe copy holds the response rule
Add header:JSON
The copied rules point at 395192 and 64958, the cache setting and the Function Instance of the copy. In the original, the same cache setting and Function Instance keep their own IDs, 395191 and 64957. A change to a cache setting or a rule of the copy leaves the original unchanged.
Clone a Firewall
The clone endpoint of a Firewall takes one required field, name: 1 to 250 characters that no other Firewall uses.
To clone the Firewall:
-
Store your token and the ID of the Firewall in shell variables. Replace the two values with your own:
Shell -
Send a
POSTrequest to the clone endpoint of the Firewall. Replaceshop-production-firewallwith the name of your copy:ShellThe API answers
202, and the response carries the new Firewall:JSON -
Store the ID of the copy:
-
List the Function Instances of the copy:
ShellThe copy holds one Function Instance,
passthrough, which runs the same Function as the original:JSON -
List the request rules of the copy, with their behaviors:
ShellThe
run_functionrule of the copy points at the Function Instance of the copy:JSON
The account holds a new Firewall named shop-production-firewall, with copies of the rules and the Function Instances of the original. The copied run_function rule points at 23051, the Function Instance of the copy.
A name that another Firewall already uses returns 400 with code 24002 and the title Name Already In Use. A body without name returns 400 with code 10059.
The copy inspects requests only once a Workload’s deployment sets that Firewall. To set it, refer to Deployment.