The Function Compute provides various function templates. In the process of creating functions in the console, you can quickly create corresponding function services based on the function templates, such as web crawlers, automatic image classification, and access to Alibaba Cloud OSS services. This topic describes how to use a function template to create a web crawler function in the Function Compute console.
- Create a Service.
- Because this function involves reading and writing from OSS, you need to add AliyunOSSFullAccess and AliyunLogFullAccess permissions to service permissions before using it. For more information, see Grant Function Compute permissions to access other Alibaba Cloud services.
- Log on to the Function Compute console.
- In the left-side navigation pane, click Services and Functions.
- In the top navigation bar, select the region where the service resides.
- On the Services page, click the target service.
- On the Functions page, click Create Function.
- On the Create Function page, click Create from Template. In the Select Function Template section, click anywhere on the image-crawler card.
- In the Basic Settings section, set the parameters and click Create.
The following table describes the parameters.
Parameter Operation Name The name of the function. Function Template By default, the template is selected. If you click Reselect Template, the function template selection step is returned. Instance Type The instance category for the function. Valid values:
- Elastic Instance
- Performance Instance
memory specifications The memory that is required to execute the function.
After the function is created, you are redirected to the Function Code tab of the function details page.
- Select Input: Select the required memory from the drop-down list.
- Manual Input: Click Manually Enter Memory Size to customize the memory size of the function. The memory specifications are described
Note The memory value must be a multiple of 64 MB.
- Elastic Instance: Valid values: [128, 3072]. Unit: MB.
- Performance Instances: Valid values: [4 to 32]. Unit: GB.
- On the Function Code tab, replace the <your region> and <your bucket name> in the code with your resource information. You can also modify other parts of the code in the code editor.
- Click the icon and select Configure Test Parameters from the drop-down list. In the Configure Test Parameters dialog box, modify the event parameters and click OK.
- Click Test Function to view the execution result of the function.