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.
Prerequisites
Console
- 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.
Console
To create the connector in Azion Console:
Access Azion Console > Connectors.
In General, enter origin-connector as the Name.
In Connector Type, select the HTTP type.
Under Address Management, enter <your-origin-hostname> in Address, without a protocol or a port.
In Transport Protocol Policy, select the option that uses HTTPS only.
The connector exists in your account, and the rule you add to the application selects it. For every field of the connector form, refer to Connectors.
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.
Console
To create the application in Azion Console:
Access Azion Console > Applications.
In General, enter first-application as the Name.
The application exists, and its Rules Engine tab holds no rules yet.
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.
Console
To create the rule in Azion Console:
Access Azion Console > Applications, and select the application you created.
In General, enter send-to-origin as the Name.
In Phase, select Request Phase. A rule’s phase cannot change after you create the rule.
Under Criteria, select the variable ${uri} and the operator starts_with, and enter / as the argument.
Under Behaviors, select Set Connector.
In Connector, select the connector you created.
The rule appears in the Rules Engine tab, under the Request heading.
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.
Console
To create the workload and its deployment in Azion Console:
Access Azion Console > Workloads.
The Create Workload page opens.
Enter a name, such as first-workload.
Under Deployment Settings, set Application to the application you created.
The workload exists, and its deployment names your application. To copy the address that the final request goes to, select Copy Workload URL.
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.