Cloud-native API Gateway trigger

Updated at:

Function Compute supports Cloud-native API Gateway as an event source. Function Compute can be configured as the backend service of an API. When a request reaches a Cloud-native API Gateway whose backend service is Function Compute, the function runs, and Function Compute returns the execution result to Cloud-native API Gateway.

Background information

The Cloud-native API Gateway trigger is similar to API Gateway triggers. After Function Compute is integrated with Cloud-native API Gateway, you can securely expose your functions as APIs and address issues such as authentication and traffic control. The difference is that when Cloud-native API Gateway is integrated with Function Compute, it no longer distinguishes between event functions and web functions. Instead, it uniformly matches requests based on routing rules and forwards them to Function Compute.

Note

Cloud-native API Gateway can be integrated only with Function Compute 3.0.

Create a function and integrate it with Cloud-native API Gateway

Step 1: Create a function

Log on to the Function Compute console and create a function. For instructions, see Function creation.

Step 2: Create a backend service

  1. Create a gateway instance.

  2. Create an HTTP API.

  3. Create a service.

    image

  4. Create a route.

    The screenshot shows the key configuration items. Keep the other configuration items at their default values.

    image

    Configuration item

    Description

    Domain Name

    Services can be managed by using a domain name. In this topic, example.com is used only as an example. Add and select your own domain name to make your service accessible through that domain name.

    Path

    Set the routing path. Different paths trigger different functions to run.

    Backend Services

    Select the Function Compute 3.0 function backend service created in Step 2.

  5. Publish a routing rule.

Step 3: Verify the result

  1. Get the second-level domain name of the environment to which the service is bound.

  2. Call the published API to run a test. This topic uses a call made with the curl command as an example.

    curl -i -X GET env-ct6ovnem1hknd****-cn-hangzhou.alicloudapi.com/fc

    The following sample response is returned:

    HTTP/1.1 200 OK
    access-control-expose-headers: Date,x-fc-request-id
    content-disposition: attachment
    content-length: 11
    content-type: application/json
    x-fc-request-id: 1-674eae6c-15b2172f-7db950e70148
    date: Tue, 03 Dec 2024 07:08:28 GMT
    req-cost-time: 29
    req-arrive-time: 1733209708197
    resp-start-time: 1733209708226
    x-envoy-upstream-service-time: 28
    server: istio-envoy
    
    hello world