All Products
Search
Document Center

Function Compute:Cloud-native API Gateway triggers

Last Updated:Mar 04, 2025

Function Compute supports using Cloud-native API Gateway as an event source. You can configure Function Compute as the backend service for APIs. When a request is received by the Cloud-native API Gateway instance configured to use Function Compute as its backend service, the gateway instance triggers the associated function to execute. Once the function completes its execution, Function Compute sends the result back to the gateway instance.

Background

Cloud-native API Gateway triggers work similarly to API Gateway triggers. For more information, see API Gateway trigger. Once Function Compute is integrated with Cloud-native API Gateway, functions can be securely exposed to clients through APIs. This setup allows for effective management of various concerns, including authentication and traffic control. Cloud-native API Gateway does not distinguish between event functions and web functions. Requests are matched and forwarded to Function Compute based on the routing rules.

Note

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

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

Step 1: Create a function

Log on to the Function Compute console to create a function. For more information, see Function creation.

Step 2: Create a backend service

  1. Create a gateway instance. For more information, see Create a gateway instance.

  2. Create an HTTP API. For more information, see Create an HTTP API.

  3. Create a service. For more information, see Create a service.

    image

  4. Create a route. For more information, see Create a route.

    Configure the required parameters as outlined below. You can leave the rest at their default settings.

    image

    Parameter

    Description

    Domain Name

    You can manage services by using domain names. The domain example.com in the preceding figure is just a placeholder. You can add and choose your own domain to access your service.

    Path

    Set your routing path. Different paths trigger different functions.

    Backend Services

    Choose the backend service you just created in Step 2.3.

  5. Publish a routing rule. For more information, see Publish a routing rule.

Step 3: Verify the result

  1. Obtain the second-level domain name of the environment bound to the service.

  2. Call the published API for testing. In this example, the curl command is used.

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

    The following code snippet shows a sample output:

    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