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 your ApsaraVideo Live service. This topic shows you how to use EdgeScript to create a script in the ApsaraVideo Live console.

Prerequisites

You understand the syntax, built-in variables, and built-in functions of EdgeScript. For more information, see Syntax, Built-in variables, and Built-in functions.

Background information

Process:1

Procedure

  1. Log on to the ApsaraVideo Live console.
  2. In the left-side navigation pane, click Domains to go to the Domain Management page.
  3. Select the streaming domain that you want to configure and click Domain Settings.
    Configure the domain name
  4. Choose Stream Management > EdgeScript. The Staging Environment tab appears.
  5. Click Add Rule. On the Add Script page, configure a script.
    Note You can create only one script for each domain name. To create more scripts for a domain name, submit a ticket.
    Use EdgeScript to create a script
    The following table describes the parameters.
    Parameter Required Description
    Script Name Yes The name of the script. The name can contain letters, digits, and underscores (_).
    Script Code Yes The code of the script.

    For more information about how to write script code, see EdgeScript manual.

    For more information about the sample code provided by ApsaraVideo Live based on scenarios, see Scenarios.

    Priority Yes The priority of the script. Valid values: 0 to 99. A greater value indicates a higher priority.
    Run Script At Yes The position where the script is executed. Valid values: Head and Foot. For more information, see Positions and priorities.
    Enable Yes Specifies whether to enable the script.
    Break No Specifies whether to skip the subsequent scripts if the current script is executed.

    Assume that you turn on this switch. If the current script is executed, the subsequent scripts are skipped.

    Extensions No EdgeScript supports extensions. You can set this parameter to _es_dbg=signature to perform response header debugging.

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

  6. Click Publish to Staging Environment.
  7. Test the script in the staging environment.
    The following figure shows how to check the IP address of the client for testing scripts in the staging environment.IP address of the test client

    On your client, find the hosts file under the path C:\Windows\System32\drivers\etc. Add the IP address of the test client to the hosts file.

  8. After you test the script, click Publish All Rules to Production Environment to publish all scripts from the staging environment to the production environment.
    Notice After you publish a script from the staging environment to the production environment, the script in the staging environment is automatically cleared.
  9. To modify scripts that you have published to the production environment, you must copy the scripts from the production environment to the staging environment, and then modify the scripts. Click Copy Rules from Production Environment to copy the scripts from the production environment to the staging environment.

    After you copy a script from the production environment to the staging environment, you can modify the copied script in the staging environment.