Create an application from a function template

更新时间:
复制 MD 格式

ESA provides a serverless execution environment at its points of presence (POPs). Write your business logic and configure trigger rules — your code runs securely and scales elastically on POPs close to users without the need to provision servers or manage infrastructure, reducing operational costs and improving response times.

Step 1: Create a function

  1. Log on to the ESA console. In the left-side navigation pane, choose Edge Computing and AI > Functions and Pages. Click Create.

  2. Set Function Templates to Function Templates, select a function template, and click Next.

    image

  3. Enter a Routine Name and Description, preview the code, and click Submit.

    image

  4. After the build completes, a public domain name is generated for preview. To bind a custom domain name, see Domain Name Configuration.imageimage

Step 2: Develop and debug

Modify and debug the function code locally, then deploy the code to the staging environment. Monitor the function's status and performance to ensure it is stable and functions correctly.

  1. Click Function Settings, select the Code tab, and write your function in JavaScript ES6.

    image

    image

  2. ESA includes a debugging environment to the right of the code editor in the console. After writing your code, click Save. In the right-side toolbar, set the HTTP request method, request header, and request body, then click Request. The console returns the response.

  3. After debugging the code, click Generate Version.

  4. Select the Deploy tab and click Release. In the dialog box, select Staging Environment to release the function. The function becomes active on the staging POPs. Send requests from a real client with a Host header to verify the response.

    image

Step 3: Deploy to production

After the function passes staging environment validation, release the code to the production environment.

  1. Select the Deploy tab and click Release.

  2. Click Production Environment, select the version to release, and click Release. The selected version of the function code deploys to all production environment POPs.

    image

Bind a custom domain name

After deployment, bind a custom domain to your project for easier access. Domain name configuration.