Creating a Function Using a Template¶
Introduction¶
FunctionGraph provides templates to automatically complete code and running environment configurations when you create a function, helping you quickly build applications.
Step 1: Prepare the Environment¶
To perform the operations described in this section, ensure that you have the FunctionGraph FullAccess permissions, that is, all permissions for FunctionGraph. For more information, see section "Permissions Management".
Step 2: Create a Function¶
Log in to the FunctionGraph console. In the navigation pane, choose Functions > Function List.
Click Create Function in the upper right corner and choose Select template.
Select the template shown in Figure 1 and click Configure.
Set Function Name to context, select any agency from the Agency drop-down list, retain default values for other parameters, and click Create Function.
Note
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.
Step 3: Test the Function¶
On the function details page, click Test. In the displayed dialog box, create a test event.
Select blank-template, set Event Name to test, and click Create.
Step 4: View the Execution Result¶
Click Test and view the execution result on the right.
Function Output: displays the return result of the function.
Log Output: displays the execution logs of the function.
Summary: displays key information of the logs.
Note
A maximum of 2 KB logs can be displayed. For more log information, see section "Querying Function Logs".
Step 5: View Monitoring Metrics¶
On the function details page, click the Monitoring tab.
On the Monitoring tab page, choose Metrics, and select a time range (such as 5 minutes, 15 minutes, or 1 hour) to query the function.
The following metrics are displayed: invocations, errors, duration (including the maximum, average, and minimum durations), and throttles.
Step 6: Delete a Function¶
On the function details page, choose Operation > Delete Function in the upper right corner.
In the confirmation dialog box, enter DELETE and click OK to release resources in a timely manner.