Deliver a live stream from Live Ingest
Create a Live Ingest connector in the region of your encoder, and send the viewers' requests of an application to it with a rule.
You create the connector that takes a live stream into Azion, and the rule that delivers that stream to viewers, from Azion Console, the Azion API, or the Azion CLI. For an HLS stream that your own origin produces, refer to Enforce HLS cache for live streaming.
Your encoder pushes the stream over RTMP to Live Ingest, which converts it to HLS: a playlist, .m3u8, and the segments it lists, .ts. Viewers never reach Live Ingest directly. They request the stream from an application, and a rule of that application names the connector.
- The encoder pushes the stream over RTMP to Live Ingest, in the region of the connector.
- Live Ingest converts the stream to HLS.
- A viewer’s player requests the stream from the application, and a rule’s Set Connector behavior names the connector.
- Azion adds the Enforce HLS cache behavior to that rule, which caches each playlist for 5 seconds and each segment for 60 seconds.
- A valid cached copy answers every viewer, and only an expired or missing copy is fetched through the connector.
Prerequisites
- An application served by a workload, with a hostname that viewers request. To create both, refer to Applications quickstart.
- An encoder that pushes RTMP with username and password authentication. Azion provides the credentials and the ingest URLs of a primary and a backup endpoint. For the requirement, refer to Ingestion.
- A personal token, for the API procedures.
- The Azion CLI installed and authorized, for the CLI procedures.
- Access to Azion Console, for the Console procedures. Refer to Access Azion Console.
This guide does not cover how you obtain the ingest URLs and credentials, or the URL layout of the playlist that viewers request. The examples use my-live-connector for the connector and us-east-1 for the region. Replace them with your values.
Create the Live Ingest connector
The connector carries one setting, the region where Live Ingest receives the stream. Choose the region closest to the encoder, not to the viewers: it shortens the path the stream travels before Azion receives it. The region accepts us-east-1, us-east-2, br-east-1, br-east-2, and br-east-3.
To create the connector in Azion Console:
Access Azion Console > Connectors.
The Create Connector page opens.
In General, enter my-live-connector as the Name.
In Connector Type, select Live Ingest.
In Region, select us-east-1. The field is required.
The my-live-connector connector exists in your account in us-east-1.
The connector exists in your account, and no viewer request reaches it until a rule of the application names it. A change to a connector reaches Azion’s distributed infrastructure in several minutes.
Send the viewers’ requests to the connector
A Request Phase rule with the Set Connector behavior sends the requests it matches to the connector. On an application that serves only the stream, the rule matches every path: ${uri} starts with /. When several matching rules carry Set Connector, only the last one runs, so keep this rule after any rule that sends every path to another connector. A new rule goes after the rules the application already has.
To create the rule in Azion Console:
Access Azion Console > Applications, and select the application that delivers the stream.
In General, enter send-to-live-ingest as the Name.
In Phase, select Request Phase.
Under Criteria, select the variable ${uri} and the operator starts_with, and enter / as the argument.
Under Behaviors, select Set Connector.
In Connector, select my-live-connector. Azion adds the Enforce HLS cache behavior to the rule.
The rule appears in the Rules Engine tab, under the Request heading.
Every request of the application now reaches the stream through the connector, under the live HLS cache policy. A new rule can take a few minutes to propagate.
Keep the cache of the stream to Enforce HLS cache
Enforce HLS cache bypasses the cache settings of the application and applies the cache policy Azion defines for live HLS. A cache setting that a Set Cache Policy behavior applies to these requests therefore has no effect, so do not add one. To confirm the rule carries the policy:
Access Azion Console > Applications, select the application, and select the Rules Engine tab.
The rule carries Set Connector, naming my-live-connector, and Enforce HLS cache.
The application caches each playlist for 5 seconds and each segment for 60 seconds. One cached copy of a segment answers every viewer who requests it in that time, so a large audience does not send each of its requests to Live Ingest.