You can use the data forwarding feature of the rules engine to forward data to Function Compute. Then, Function Compute runs function scripts to process data.

Prerequisites

  • A Function Compute service and a function are created. The function is configured and can run as expected after verification. For more information, see the Function Compute documentation.
    Notice If you use an IoT Platform Enterprise Edition instance, Function Compute must be deployed in the region where the Enterprise Edition instance resides.
  • A data forwarding rule is created and an SQL statement that is used to process data is written. For more information, see Configure a data forwarding rule.

Background information

The rules engine uses the data forwarding feature to forward device data to Function Compute. Then, Function Compute runs business-specific function scripts to implement various business features.

The following figure shows the data forwarding process.

Forward data to Function Compute

Procedure

  1. Log on to the IoT Platform console.
  2. On the Overview page, find the instance and click the instance name to go to the Instance Details page.
    Notice Enterprise Edition instances are available only in the China (shanghai) and Japan (Tokyo) region. If your IoT Platform is not activated in the China (shanghai) or Japan (Tokyo) region, skip this step.
    Overview
  3. In the left-side navigation pane, choose Rules Engine > Data Forwarding.
  4. Click View next to the rule that you want to manage. The Data Forwarding Rule page appears.
    Notice If the new version of the Data Forwarding page is displayed, you must click Back to Previous Version in the upper-right corner, and then click View in the Actions column corresponding to the rule that you want to manage.
  5. In the Forward Data section, click Add Operation.
  6. In the Add Operation dialog box, select Send Data to Function Compute from the Operation drop-down list. Follow the instructions as prompted to configure other parameters and click OK.
    Parameter Description
    Operation Select Send Data to Function Compute.
    Regions Select the region in which your Function Compute service is deployed.
    Services Select a Function Compute service.

    You can click Create Service to go to the Function Compute console and create a service. For more information, see Manage microservices.

    Function Version Valid values:
    • Use Default Version: Use the default version of the Function Compute service. The default version is LATEST.
    • Select Version: Select the version of the Function Compute service that you want to release.

      You can click Create Version to go to the Function Compute console and create a version. For more information, see Manage versions.

    • Select Alias: Select the alias that you want to specify for the version of the Function Compute service.

      You can click Create Alias to go to the Function Compute console and create an alias. For more information, see Manage aliases.

    Function Select the function that you want to use to receive data.

    You can click Create Function to go to the Function Compute console and create a function. For more information, see Manage functions.

    Authorize Grant IoT Platform the permissions to write data to Function Compute.

    If no RAM roles exist, click Create RAM Role to go to the Resource Access Management (RAM) console, create a RAM role, and then grant permissions to the RAM role. For more information, see Create a RAM role.

  7. Go to the Data Forwarding page, find the rule that you managed, and then click Start in the Actions column of the rule.
  8. Perform a test.
    1. Send messages to the destination topic based on the topic category that is defined in the SQL statement that is specified in the data forwarding rule. For information about how to use topics, see What is a topic?. For more information about how to debug upstream or downstream messaging between devices and IoT Platform, see Device simulation.
    2. Log on to the Function Compute console. On the details page of the function, the Logs tab displays the execution logs of the function. In the upper-right corner of the details page, click Monitoring Dashboard to view the monitoring statistics of the function.
      Notice The monitoring statistics of a function are generated 5 minutes after the function is executed.

Examples

Push device data to DingTalk groups