Creating Your First FunctionGraph Function
-
FunctionGraph hosts and computes functions in a serverless context. It automatically scales up/down resources during peaks and spikes without requiring the reservation of dedicated servers or capacities. You will be billed based on actual usage.
-
This document describes how to create and test a HelloWorld function so that you can quickly understand the basic functions of FunctionGraph.
Step1 Preparing the Environment
Procedure
1. Visit HUAWEI CLOUD, and choose Products > Computing > FunctionGraph. On the product page of FunctionGraph, click Get Started and log in to the FunctionGraph console.
2. In the navigation pane, choose Functions > Function List. Then click Create Function.
Note
This section assumes that you have permissions to perform all the operations. For details, see User Permissions.
1
User login
2
Creating a function
View Image
Step2 Creating a Function
Procedure
1. Select Create from scratch for Template.
2. Enter the function name HelloWorld.
3. Select default for App.
4. Do not use any agency. If you need to create an agency, see Creating an Agency.
5. Click Create Now.
Note
If you select a system template, the built-in information (including the runtime, handler, code, memory, and timeout) of the template is automatically loaded. For more information, see Function Templates.
1
Creating a function
View Image
Step3 Testing the Function
Procedure
1. On the function details page, choose Select test event > Configure test event.
2. In the Configure Test Event dialog box,
Click Create new test event.
Select blank-template.
Enter the event name test.
Enter the test event {"message":"HelloWorld"}.
3. Click Save.
4. On the function details page, select test event test and click Test.
Note
For details on how to trigger a function, see Trigger Management.
1
Creating a test event
2
Configuring a test event
3
Testing the function
View Image
Step4 Viewing the Execution Result
Procedure
Click Details to view the execution result.
- Function Output: Displays the return result of the function.
- Summary: Displays key information of the logs.
- Log Output: Displays the execution logs of the function.
Note
The Log Output area displays a maximum of 4 KB logs. To view more logs, see Querying Logs.
1
Viewing the execution result
View Image
Step5 Viewing Metrics
After creating a function and trigger, you can monitor the real-time invocation and running statuses of the function.
Procedure
- On the function details page, select a version or alias, and click the Monitoring tab.
- On the Monitoring tab page, select an interval (5 minutes, 15 minutes, and 1 hour), and view the running status of the function.
Note
FunctionGraph presents the following metrics: invocation count, invocation errors, invocation duration (including the maximum, average, and minimum invocation durations), and throttled invocations.
1
Viewing metrics
View Image
Step6 Deleting a Function
You can delete unused functions to release resources.
Procedure
- On the Function List page, select a search criterion (function name, runtime, or App name), enter a keyword, and click to search for the function you want to delete.
- Click Delete in the same row as the function to be deleted.
- In the Delete Function dialog box, enter DELETE (case-sensitive), and click Yes to confirm the deletion.
1
Deleting a function
2
Confirming the deletion
View Image
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.