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
- An IoT Platform instance whose data can be forwarded to Function Compute is created in a region that supports data forwarding to Function Compute.
Supported instance Supported region Enterprise Edition instances: Standard and Video - China (Shanghai)
- Japan (Tokyo)
Public instances - China (Shanghai)
- Singapore
- Japan (Tokyo)
- 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.
Important
- When you create the function, you can set the Function Type parameter only to Event Function.
- If you use an IoT Platform Enterprise Edition instance, Function Compute must be activated in the same 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.
Usage notes
You can use the new version or old version of the data forwarding feature to forward data to Function Compute. For more information about how to use the new version of the data forwarding feature, see Use the new version of the data forwarding feature to forward data to Function Compute.
Procedure
- Log on to the IoT Platform console.
- On the Overview page, find the instance that you want to manage and click the instance name to go to the Instance Details page.
Important Enterprise Edition instances are available in the China (Shanghai) and Japan (Tokyo) regions. If the Enterprise Edition instances are unavailable in the region that you select, skip this step.
- In the left-side navigation pane, choose .
- Click View next to the rule that you want to manage. The Data Forwarding Rule page appears.
Important If the new version of the Data Forwarding page is displayed, click Back to Previous Version in the upper-right corner, and then click View in the Actions column of the rule that you want to manage.
- In the Forward Data section, click Add Operation.
- In the Add Operation dialog box, select Send Data to Function Compute from the Operation drop-down list. Configure other parameters as prompted and click OK. The following table describes the parameters.
Parameter Description Operation Select Send Data to Function Compute. Region Select the region where your Function Compute service is deployed. Service 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 services.
Function Version The scope of the update. Valid values: - Use Default Version: Use the default version of the Function Compute service. The default version is LATEST.
- Select Version: Select the service version that you published.
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 specified 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.
Grant permissions 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.
- Go to the Data Forwarding page, find the rule that you managed, and then click Start in the Actions column of the rule.
- Perform a test.