All Products
Search
Document Center

Blockchain as a Service:Function Compute

Last Updated:Jul 21, 2023

To enable various events on a blockchain to automatically trigger off-chain business logic, you can upload the business logic code to the Function Compute service and configure the mapping between blockchain events and the Function Compute code. After the mapping is configured, if Alibaba Cloud Blockchain as a Service (BaaS) detects a blockchain event, it prepares computing resources and automatically runs the off-chain code in a flexible and reliable way.

Integrate Alibaba Cloud BaaS with Alibaba Cloud Function Compute

Note

Before you integrate Alibaba Cloud BaaS with Alibaba Cloud Function Compute, you must install the cloud service integration module.

  1. Log on to the Alibaba Cloud BaaS console. Go to the Hyperledger Fabric > Overview page from the left navigation bar.

  2. Find the target organization in the My Organizations section and click Cloud service integration on the right side.

  3. Click the Function Compute tab.

  4. Click Condition detection to check the status of cloud service integration.

  5. If you have not enabled the Alibaba Cloud Function Compute service, click Enable service.

  6. If you have not authorized Alibaba Cloud BaaS to access the Function Compute service, click Authorization Service to authorize Alibaba Cloud BaaS.

  7. If the following figure appears, the integration is complete. Click Add configuration and configure an event trigger by referring to the following procedure.Configure an event trigger

Configure a Function Compute trigger

Note

Before you configure a Function Compute trigger, you must install the cloud service integration module and integrate Alibaba Cloud BaaS with Alibaba Cloud Function Compute.

  1. On the Function Compute tab, click Add configuration.

  2. In the Add function compute configuration side pane that appears, set the following parameters:

    • Name: the name of the trigger for easy identification.

    • Channel/network: the fabric channel used by the trigger to listen to and push events.

    • Event type: the type of events you want to push to an external service. For information about event types, see Subscribe to events.

    • Function compute domain name: the domain name of the Function Compute service. You can view the endpoint on the Common Info page in the Function Compute console or query the endpoint in Function Compute service addresses.

    • Service name: the name of the service to which the target function belongs.

    • Function name: the name of the target function.

    • Version: the service version of the target function, which is optional.

    • Failure threshold: Advanced option. After the number of failure exceeds this value, the trigger enters the failed state and stops processing. -1 means the number of failure is unlimited, and the trigger will not enter the failed state.

    • Filter: Advanced option. Optional. For more information, see Use Filter.

  3. Click Add. After the trigger is added, it appears in the list.Creation completed

    Note

    When a trigger pushes a blockchain event to an integrated service, a service processing error or parameter configuration error causes the trigger status to become Exception. You can move the pointer over Exception to view the error information. When the integrated service returns an exception, the trigger retries processing. If the retry fails multiple times, the trigger discards the event, which is counted as one failure. If the aggregate number of failure doesn’t exceed the failure threshold, the trigger pushes subsequent events. If the aggregate number of failure exceeds the failure threshold, the trigger enters the failed state and stops processing. You can repair the trigger or relevant service and enable it again, the failure number will return to zero. Block height field indicates the latest block has been processed by the trigger, which reflects the progress of the trigger.

  4. After a trigger is created, you can perform the following operations:

  • Delete: deletes the trigger.

  • Disable: stops event pushes to the service for which you create the trigger.

  • Enable: pushes events to the service for which you create the trigger. After a trigger is enabled, it pushes the events of the latest block. The events that are generated while the trigger is disabled are discarded.