In the ApsaraVideo Live console, you can create scripts based on the EdgeScript coding standard and publish the scripts to the production environment. This way, you can customize the features of ApsaraVideo Live. This topic describes how to configure EdgeScript in the ApsaraVideo Live console.

Prerequisites

The EdgeScript service is activated. To activate the service, submit a ticket. For more information, see Contact us.

Background information

Use EdgeScript to manage scripts in one of the following scenarios as needed:
  1. Create scripts.
  2. Modify existing scripts.

Create scripts

  1. Log on to the ApsaraVideo Live console.
  2. In the left-side navigation pane, click Domains. The Domain Management page appears.
  3. Find the streaming domain that you want to configure and click Domain Settings.
    001
  4. Choose Streaming Management > EdgeScript. The Staging Environment tab appears.
  5. Click Create Script. On the Add Script page, configure a script.
    Note You can create only one script for each domain name. If you want to create multiple scripts for a domain name, submit a ticket.
    Create a script
    The following table describes the parameters.
    ParameterRequiredDescription
    Script NameYesSpecify a name for the script. The name can contain only letters, digits, and underscores (_).
    Script CodeYesEnter the code of the script.
    PriorityYesSpecify a priority for the script. Valid values: 0 to 99. A value of 0 specifies the highest priority, and a value of 99 specifies the lowest priority.
    Run Script AtYesSpecify the position in which you want to execute the script.
    EnableYesSpecify whether to enable the script.
    BreakNoSpecify whether to skip the subsequent scripts if the current script is matched.

    After you turn on Break, the subsequent scripts are skipped if the current script is matched.

    ExtensionsNoEdgeScript supports extensions. Only _es_dbg=signature is supported. This field is used to add a response header for debugging.

    After you configure the script, you can click Open Debugging Tool to perform single request testing. This step is optional.

    1. Configure the following parameters: Request Method, Protocol, HOST, URL, Request Header, and Request Body.
      Note
      • You can ping the domain name staging.myalicdn.com to obtain the IP address of the test node in the staging environment. Then, enter the IP address in the HOST field.
      • Sample URL: http://example.com/image/***.jpg.
      • Sample Request Header: Accept-Encoding: gzip, deflate, br.
    2. Click Submit for Testing to send a request.
    3. Receive the response.
  6. Click Publish to Staging Environment. Test the script in the staging environment.
    The IP address of the test node in the following figure is only for reference. The actual IP address of the test node in the staging environment shall prevail.The IP address of the test node
    On your client, find the hosts file in the path C:\Windows\System32\drivers\etc. Add the IP address of the test node to the hosts file.
    Important
    • In a Windows operating system, the path is C:\Windows\System32\drivers\etc\hosts.
    • In a macOS operating system, the path is /etc/hosts.
  7. After you test the script, click Publish All Scripts to Production Environment to publish all scripts from the staging environment to the production environment.
    Important After you publish the scripts from the staging environment to the production environment, the scripts are automatically deleted from the staging environment.

Modify existing scripts

  1. Click Roll Back Configurations in the Staging Environment to roll back configurations in the staging environment to the initial status.
  2. Click Copy Scripts from Production Environment to copy the scripts from the production environment to the staging environment.
  3. On the Staging Environment tab, find the script that you want to modify. Click Modify in the Actions column to modify the script.
  4. After you modify the script, you can click Open Debugging Tool to perform single request testing.
  5. Click Publish to Staging Environment. Test the script in the staging environment.
  6. After you test the script, click Publish All Scripts to Production Environment to publish all scripts from the staging environment to the production environment.
    Important After you publish the scripts from the staging environment to the production environment, the scripts are automatically deleted from the staging environment.