Applications quickstart
Create an application that sends every request to your origin through a connector, serve it from a workload, and request it.
This guide instructs you through serving your origin’s content from your first application.
- Create a connector that reaches your origin over HTTPS.
- Create an application.
- Add a rule that sends every request to the connector.
- Serve the application from a workload.
- Send a request to the workload domain and get your origin’s answer.
Five parts make the chain, listed in the order this guide uses them:
- The connector holds the address of your origin and the way Azion connects to it.
- The application holds the rules that decide what happens to a request. A new application has no rules.
- The rule on the application pairs a criterion with a behavior. In this guide, the criterion matches every request, and the Set Connector behavior names the connector.
- The workload holds the domain that receives requests. Its deployment names the application.
- The request to the workload domain meets the rule, and the connector passes it to your origin.
A connector receives requests only once a rule names it, and an application only once a deployment names it.
On an application, you enable three Products: Cache, Application Accelerator, and Image Processor. A new application starts with Cache turned on and the other two turned off, and this guide changes none of them. To turn one on later, open the application’s Main Settings tab, turn on its switch in Modules, and select Save. The quickstart of each Product begins where this guide ends, with an application that already serves content.
The prerequisites and the five stages show the steps of one interface at a time. Select yours:
Prerequisites
- An Azion account. For more information, refer to Create an account.
- An origin server that answers HTTPS requests on port
443under a public hostname. This guide writes that hostname as<your-origin-hostname>. curl, to send a request through the workload.
You also need access to Azion Console. For more information, refer to Access Azion Console.
Create a connector to your origin
A connector holds the address of your origin and the settings Azion uses to reach it. You create it on its own, outside any application, and a rule names it later. This connector has one address and connects to your origin over HTTPS. It sends your origin’s hostname in the Host header.
To create the connector with the Azion CLI, put it in a JSON file first. Save this body as connector.json, and replace <your-origin-hostname> in both places:
addresses lists the origin servers, and connection_options.host is the Host header the connector sends. force_https makes every connection to the origin use HTTPS.
Create the connector from the file:
Record the ID of the new connector from the command output: the rule passes it as <connector-id>.
Create the application
An application holds the rules that decide what happens to each request. It needs only a name, and every other setting keeps its default. Until a rule names a connector, the application has no origin to send requests to.
To create the application with the Azion CLI:
The output carries the application’s ID:
The application is active and has no rules. Cache and Functions start turned on, and Application Accelerator and Image Processor start turned off. Record the ID: the rule and the deployment pass it as <application-id>.
Send every request to the connector
A rule in Rules Engine for Applications pairs criteria with behaviors. This rule runs in the request phase. Its criterion, ${uri} starting with /, matches every request. Its behavior, Set Connector, sends each matching request to your connector. For more information, refer to Set Connector.
The criterion uses ${uri}, not ${request_uri}. ${request_uri} needs Application Accelerator turned on. On an application without it, the API refuses the rule with 400 and error 25047, Missing Required Modules.
To create the rule with the Azion CLI, keep the rule in a file: on a command line, the shell would expand ${uri}. Save this body as rule.json, and replace <connector-id> with the ID of your connector:
Each group in criteria opens with a condition whose conditional is if. Create the rule in the request phase of your application. Replace <application-id> with the ID of your application:
The output carries the rule’s ID:
The rule is active on your application, and it sends every request to your connector.
Serve the application from a workload
A workload holds what receives requests: the domain, the protocols, and the certificates. The application holds none of these settings. The workload’s deployment names the application it runs, and the current deployment is the one that serves requests. A new workload answers on a workload domain that Azion assigns under map.azionedge.net.
To create the workload with the Azion CLI:
The output carries the workload’s ID:
Create the deployment that names your application. Replace <workload-id> and <application-id>:
The output carries the deployment’s ID:
--current true makes this deployment the one the workload serves. It names your application and no firewall.
To find the workload domain, describe the workload in JSON:
The workload_domain field holds the domain that the final request goes to.
Send a request through the workload
This stage needs only curl, whichever interface you used to build the chain. In the command, replace <your-workload-domain> with the workload domain of the workload you created.
A new workload does not answer at once. Its first deployment can take several minutes to reach traffic, and no duration is guaranteed. Until then, the workload domain answers 404 with a placeholder page. While the deployment spreads, answers to the same request can alternate between that 404 and your origin’s response. Repeat the request until the answer comes from your origin.
Send a request to the root path of your workload domain:
The response is the one your origin returns for /: its status, its headers, and its body. Every other path reaches your origin the same way, because the rule matches every URI that starts with /. Your application now sends every request on its workload domain to your origin through the connector.