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

Prerequisites

  • A Function Compute service and function are created. The function is configured and can run as expected after verification. For more information about how to use Function Compute, see the Function Compute documentation.
  • A data forwarding rule is created and an SQL statement that is used to process data is written. For more information, see Configure data forwarding rules.

Background information

The following figure shows the data forwarding procedure.

Forward data to Function Compute

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

Procedure

  1. Log on to the IoT Platform console.
  2. In the left-side navigation pane, choose Rules > Data Forwarding.
  3. Click View next to the required rule. The Data Forwarding Rule page appears.
  4. In the Data Forwarding section, click Add Operation.
  5. In the Add Operation dialog box, select Send to Function Compute. Set the required parameters as prompted and click OK.
    Parameter Description
    Select Operation Select Send to Function Compute.
    Region Select a region where Function Compute runs.
    Services Select a Function Compute service.

    To create a service in the Function Compute console, click Create Service. For more information, see the Function Compute documentation.

    Function Select a function that is used to receive data.

    To create a function in the Function Compute console, click Create Function.

    Authorization Authorize IoT Platform to write data to Function Compute.
  6. Go to the Data Forwarding page, find the required rule, and then click Start in the Actions column of the rule.
  7. Run a test.

    Publish a message to the topic that is specified in the SQL statement of the rule. Then, log on to the Function Compute console and click the required function. On the Logs tab of the details page, view the execution logs. In the upper-right corner of the tab, click Monitoring. On the page that appears, view the monitoring history of the function. The system shows monitoring data about 5 minutes after the monitoring data is generated.

Examples

Report temperature and humidity data to a DingTalk chatbot