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.
Log on to the Function Compute console.
In the left-side navigation pane, click Services & Functions.
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).
On the Services page, click Create Service to create a service.
After the service is created, click the service name, and click Create Function on the Functions page that appears.
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.
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 function code. For more information about how to write the code, see the function demo in "Write user-defined resolution functions".
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".
Click Test Function. Make sure that the function can be executed properly.
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.
Set the Description parameter and click OK.
The configurations in the Function Compute console are complete.