This topic describes how to create a user-defined function in the Function Compute console, debug the function, and publish the service version that contains the function settings.
Procedure
Log on to the Function Compute console.
In the top navigation bar, select a region.
NoteThe custom resolution function policy of HTTPDNS supports Function Compute services in the following regions: China (Hong Kong) and Singapore.
On the Services page, click Create Service.
After the service is created, click the service name. On the page that appears, click Create Function.
On the Create Function page, configure the parameters based on your business requirements. After the parameters are configured, click Create. For more information, see Manage functions. In this topic, set the Handler Type parameter in the Basic Settings section to Event Handler.
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.
Enter the code for the function. For more information, see .
You can also select Configure Test Parameters from the Test Function drop-down list. In the Configure Test Parameters panel, configure the Event Name parameter and the input parameters for the event. For more information about how to configure input parameters, see .
Click Test Function. Make sure that the function can be executed properly.
Return to the Functions page. In the left-side navigation pane, click Versions. On the page that appears, click Publish Version.
NoteThe system will generate a service version. The version number is incremented by one each time you publish a version. The latest version of a Function Compute service is not recommended by the custom resolution feature of HTTPDNS. Therefore, you must save the generated version number for later use.
In the panel that appears, configure the Description parameter and click OK.
The configurations in the Function Compute console are complete.
For more information about how to apply the configurations of the Function Compute service to the function policy of HTTPDNS, see Add a Function Compute policy.