This topic describes how to write, debug, and save a version of a custom function in the Function Compute console.
HTTPDNS supports function configurations for both Function Compute (FC) 2.0 and FC 3.0. This topic describes how to create a function in the Function Compute console.
Create a 3.0 function
Log on to the Function Compute console. In the top menu bar, select a Region.
In the navigation pane on the left, select Functions. On the Functions page, click Create Function.

On the Create Function page, select 'Event Function' and configure the parameters. For the code example, select the 'HTTPDNS Custom Resolution' template. After you finish the configuration, click Create to open the function editor.

After the editor initializes, enter the function code. For more information about the code configuration, see Write a custom resolution function. If you selected the 'HTTPDNS Custom Resolution' template, you can skip this step.
Test the function. For more information about how to set the input parameters, see Write a custom resolution function. Click Test Function. Verify that the function executes correctly and that the returned data is as expected.

After the test is complete, click Deploy Code. Verify that the code is deployed.
Click Version Management, enter a description, and then create a version.

The sample configuration in the FC 3.0 console is now complete. You can now go to the HTTPDNS console to add a Function Compute policy that corresponds to the function.
Create a 2.0 function
We recommend that you use FC 3.0 because FC 2.0 is no longer recommended. For more information about the differences between them, see Comparison and compatibility between Function Compute 3.0 and Function Compute 2.0
Log on to the Function Compute console. In the top menu bar, select a Region.

In the navigation pane on the left, select Services. On the Services page, click Create Service.
After the service is created, on the Function Management page, click Create Function.
On the Create Function page, select 'Create with Built-in Runtime'. For the handler type, select 'Event Request'. Configure the other parameters as needed. After you finish the configuration, click Create.

Test the function. For more information about how to set the input parameters, see Write a custom resolution function. Click Test Function. Verify that the function executes correctly and that the returned data is as expected.
Enter the function code. For more information about the code configuration, see Write a custom resolution function.

Alternatively, you can select Test Function > Configure Test Request. For more information about how to set the input parameters, see Write a custom resolution function. Verify that the function executes correctly and that the returned data is as expected.

After the test is complete, click Deploy Code. Verify that the code is deployed.
In the upper-right corner, click Publish Version. Enter a Description and click OK.

The system generates an auto-incrementing version number for the service. Because the custom domain name resolution feature of HTTPDNS does not recommend using the LATEST version of a function, you must save the generated version number for later use.
The sample configuration in the FC 2.0 console is now complete. You can now go to the HTTPDNS console to add a Function Compute policy for the function.
For more information about how to configure the HTTPDNS Function Compute policy to use the new service, see Add a Function Compute policy.