All Products
Search
Document Center

HTTPDNS:Create a function in Function Compute

Last Updated:Sep 19, 2022

This topic describes how to create a custom function in the Function Compute console, debug the function, and publish the service version that contains the function settings.

Procedure

  1. Log on to the Function Compute console.

  2. In the left-side navigation pane, click Services & Functions.

  3. In the top navigation bar, select the region.

    Note

    The Software-defined DNS (SDNS) feature of HTTPDNS supports Function Compute services in the following regions: China (Hong Kong) and Singapore (Singapore).

    fig1
  4. On the Services page, click Create Service to create a service.

  5. After the service is created, click the service name, and click Create Function on the Functions page that appears.

  6. On the Create Function page, set the parameters based on your business requirements. Then, click Create. For the detailed procedure, see "Manage functions"in the Function Compute documentation. In this example, Request Type is set to Event Requests in Basic Settings.

  7. After the function is created, click the name of the function in the function list. You are navigated to the Code tab of the Function Details page.

  8. Enter the function code. For more information about how to write the code, see the function demo in "Write user-defined resolution functions". fig1

  9. You can also select Configure Test Parameters from the Test Function drop-down list. In the Configure Test Parameters panel, set the Event Name parameter and the input parameters for the event. For more information about how to configure input parameters, see the example of input parameters in "Write user-defined resolution functions". fig2

  10. Click Test Function. Make sure that the function can be executed properly. fig3

  11. Return to the Functions page. In the left-side navigation pane, choose Versions and click Publish Version on the page that appears.

    Note

    The system will generate a service version. The version number is incremented by one each time you publish a version. You can specify only an exact version number rather than the latest version of a Function Compute service when using HTTPDNS. Therefore, you must save the generated version number for later use.

  12. Set the Description parameter and click OK.

The configurations in the Function Compute console are complete.