Function Compute provides various function templates. You can use function templates to create functions in the Function Compute console with efficiency. For example, you can create web crawler functions, functions used to automatically classify images, and functions used to access Object Storage Service (OSS). 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 desired service.
  5. On the Functions page, click Create Function.
  6. On the Create Function page, click Create from Template. In the section to select templates, click the image-crawler card.
  7. In the Basic Settings section, configure the parameters and click Create.
    enter parameter value

    The following table describes the parameters.

    Parameter Description
    Function Name Enter a custom name for the function.
    Function Template By default, the template you selected is used. You can click Reselect Template to use another template.
    Instance Type Select an instance type.
    • Elastic Instance
    • Performance Instance
    Memory Capacity Specify the size of the memory that is used to execute the function.
    • Select a value: Select a value from the drop-down list.
    • Input a value: Click Enter Memory Size and enter a value for the memory size. This method can be used for only elastic instances. Valid values: [128, 3072]. Unit: MB.
      Note The value must be a multiple of 64 MB.
    After the function is created, you are navigated to the Code tab of the Function Details page.
  8. On the Code tab, replace <your region> and <your bucket name> in the code with the actual names, and then click Save and Deploy. 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 panel, modify the event parameter and click OK.
  10. Click Test Function to view the execution result of the function.