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.

Prerequisites

Procedure

  1. Log on to the Function Compute console.
  2. In the left-side navigation pane, click Services and Functions.
  3. In the top navigation bar, select the region where the service resides.
  4. On the Services page, click the target service.
  5. On the Functions page, click Create Function.
  6. On the Create Function page, click Create from Template. In the Select Function Template section, click anywhere on the image-crawler card.
    choose template
  7. In the Basic Settings section, set the parameters and click Create.
    enter parameter value

    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.
    • 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 as follows:
      • Elastic Instance: Valid values: [128, 3072]. Unit: MB.
      • Performance Instances: Valid values: [4 to 32]. Unit: GB.
      Note The memory value must be a multiple of 64 MB.
    After the function is created, you are redirected to the Function Code tab of the function details page.
  8. 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.
  9. Click the xialatubiao 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.
    Test Event
  10. Click Test Function to view the execution result of the function.
    Execution result of the function