Help Center/ FunctionGraph/ User Guide/ Building Functions/ Creating a Function Using a Template
Updated on 2023-11-30 GMT+08:00

Creating a Function Using a Template

Overview

FunctionGraph provides templates to automatically complete code, and running environment configurations when you create a function, helping you quickly build applications.

Creating a Function

  1. Log in to the FunctionGraph console. In the navigation pane, choose Templates.
  2. On the page that is displayed, select the FunctionGraph service, select the context-class-introduction template for Python 2.7, and click Configure.

    The context-class-introduction template for Python 2.7 is used as an example. You can also select other templates.

  3. After you select a function template, the built-in code and configurations of the template are automatically loaded. The Create Function page is displayed.
  4. Set Function Name to context, select a created agency, retain default values for other parameters, and click Create Function.

    If no agency is configured, the following message will be displayed when the function is triggered:

    Failed to access other services because no temporary AK, SK, or token has been obtained. Please set an agency.
  5. Set the parameters based for your service requirements.

Triggering a Function

  1. On the Code tab page of the context function, click Test in the upper right corner.
  2. In the Configure Test Event dialog box, select Blank Template and click Create.
  3. Click Test. After the test is complete, view the test result.
    Figure 1 Successful execution result