This topic describes how to create an HTTP trigger in the Function Compute console.

Prerequisites

Create service

Background information

Creating an HTTP trigger is different from creating other types of triggers. The HTTP trigger-related parameters are configured when you create the function. However, parameters of other types of triggers are configured in the created function.

Procedure

  1. Log on to the Function Compute console.
  2. In the top navigation bar, select a region.
  3. In the left-side navigation pane, click Service/Function.
  4. Click Create Function.
  5. On the Create Function page, choose HTTP Functions > Next.
    create-function
  6. Configure the function.
    In the Configure Function section, set parameters as required.config-function
    Parameter Settings Example
    Service Name Select the target service from the drop-down list. service
    Function Name Enter the name of the function. function
    Runtime Select a language that you are familiar with, such as Python, Java, PHP, or Node.js. python3
    Function Handler Enter the function handler. The value is in the format of [File name].[ Function name]. index.handler
    Memory Set memory for function execution. The default value is 512 MB. The maximum value is 3072 MB. 512 MB
    Timeout Configure a timeout period. The default value is 60 seconds. The maximum value is 600 seconds.

    If the specified timeout period expires, the function fails to run.

    60
    Single Instance Concurrency The number of requests that can be concurrently processed by a single Function Compute instance. This parameter is unavailable for Python.
  7. Configure the trigger.
    In the Configure Trigger section, set parameters as required.config-trigger
    Parameter Settings Example
    Trigger Name Enter the name of the trigger. HTTP-Trigger
    Authorization Select an authorization type. Valid values:
    • anonymous: If this option is selected, no authorization is required, anonymous access is supported, and the security level is low. That means anyone can send an HTTP request to call your function.
    • function: If this option is selected, authorization is required, anonymous access is not supported, and the security level is high. For more information, see Authorization.
      Note Authorization and Date information needs to be passed in the HTTP request header. In this case, Date is in GMT format and is involved in the signature calculation. The server will calculate the signature based on the value of Date and compare it with the passed Authorization value. If the signature is the same as the Authorization value and the difference between the current time and the value of Date is less than 15 minutes, the authorization is passed.
    anonymous
    Method The request method supported by the HTTP trigger. You can choose multiple methods. Valid values:
    • GET
    • POST
    • PUT
    • DELETE
    • HEAD
    • PATCH
    GET POST
  8. Click Create.
    The created function is displayed under the target service.result-function
    Click the target function and then click the Triggers tab. The created HTTP trigger is displayed in the trigger list.result-trigger

What to do next

  1. Write a function
  2. Test a function