Creating a Function Using a Template
Overview
FunctionGraph provides function templates for different scenarios. When you create a function using a template, the template automatically configures the function code, environment variables, and triggers.
You can filter function templates by function type, scenario, cloud service, or runtime. Click View details to view the description, input and output parameters, and precautions of a function template.

Prerequisites
To perform the operations described in this section, ensure that you have the FunctionGraph Administrator permissions, that is, the full permissions for FunctionGraph. For more information, see Permissions Management.
Creating a Function Using a Template
The context-class-introduction template for Python 3.6 is used as an example. You can also select other templates.
- Log in to the FunctionGraph console, and create a function using either of the following methods:
- In the navigation pane, choose Functions > Function List. Then click Create Function in the upper right corner. Select Select template for the creation mode.
- In the navigation pane, choose Templates. Hover the cursor over the target template. Click Configure. The Create Function page is displayed.
- After you select a function template, the code and configuration information built in the template are loaded, as shown in Figure 2. For details, see Table 1.
Table 1 context template parameter table Parameter
Description
Example Value
Templates
The selected function template is displayed by default. To change it, click Reselect.
context-class-introduction
Region
Select the region where the function is located.
Regions are geographic areas isolated from each other. Resources are region-specific and cannot be used across regions through internal network connections. For low network latency and quick resource access, select the nearest region.
CN East-Shanghai1
Function Name
Enter a function name. The naming rules are as follows:
- Consists of 1 to 60 characters, and can contain letters, digits, hyphens (-), and underscores (_).
- Starts with a letter and ends with a letter or digit.
context-class-introduction-python-36
Enterprise Project
Select the enterprise project to which the function belongs. Enterprise projects let you manage cloud resources and users by project.
The default value is default. You can select the created enterprise project.
If the Enterprise Management service is not enabled, this parameter is unavailable. For details, see Enabling the Enterprise Project Function.
default
Agency
Select an agency for the function. An agency is used to authorize FunctionGraph to access other cloud services. For example, if FunctionGraph needs to access LTS or VPC, you must select an agency with required service permissions. If FunctionGraph does not access any cloud services, you do not need to select an agency.
By default, Use no agency is used. You can select an existing agency.
If no default agency is available, FunctionGraph allows you to quickly create a default agency named fgs_default_agency. For details, see Default Agency.
Use no agency
Runtime
Select a runtime to compile the function. The runtime language is automatically selected based on the function template and cannot be changed.
Python 3.6
Advanced Settings
- Public Access: If this feature is enabled, functions can access services on the public network through the default NIC. The public network access bandwidth is shared among users and applies only to test scenarios.
- VPC Access: If this feature is enabled, functions will use the NIC bound to the configured VPC for network access, and the default NIC of FunctionGraph will be disabled. That is, the Public Access parameter does not take effect.
To enable this feature, you need to configure an agency with VPC management permissions. If you select Use no agency in the Basic Information area, this feature cannot be enabled.
- Collect Logs: After it is enabled, logs generated during function execution will be reported to LTS.
LTS will be billed on a pay-per-use basis. For details, see LTS Pricing Details.
- Static Encryption with KMS (supported only in the LA-Sao Paulo1 region): Select whether to use KMS static code encryption.
DEW is billed by the pay-per-use mode. For details, see DEW Billing.
- Public Access: Enabled.
- VPC Access: Disabled.
- Collect Logs: Disabled.
- Static Encryption with KMS: Disabled.
- Click Create Function. For details about other configurations, see Configuring Functions.
Helpful Links
- For FAQs about function creation, see Function Creation FAQs.
- Manage function templates through APIs. For details, see Function Template APIs.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot