The introduction of smart contracts in blockchain networks has created that business logic tier that was missing in the first evolution of blockchain. Smart contracts offer the possibility to apply conditional logic to transactions before they are executed. Still, smart contracts can operate on data that it’s stored on the blockchain digital ledger only. Business processes, however, rarely run in isolation. They often need data integration with external systems and devices.
Requirements of these processes may consist of transactions initiated on a distributed ledger that include data from an external system, service, or device. They may also want external systems to react to events raised by smart contracts in response to validation logic.
Azure Blockchain Workbench
Azure Blockchain Workbench offers a REST API that provides the ability to both send transactions from external systems to smart contracts included in an Azure Blockchain Workbench application, as well as send event notifications to external systems based on changes that take place within an application.
For data integration scenarios, Azure Blockchain Workbench includes a set of database views that merge a combination of transactional data from the blockchain and meta-data about applications and smart contracts. In addition, some scenarios, such as those related to supply chain or media, may also require the integration of documents. While Azure Blockchain Workbench does not provide API calls for handling documents directly, documents can be incorporated into an Azure blockchain application.
This article described the patterns identified for implementing inbound type of data integrations between external systems and a blockchain workflow running in Azure Blockchain Workbench.
REST API-based integration
Capabilities within the Azure Blockchain Workbench generated web application are exposed via the REST API. Capabilities include Azure Blockchain Workbench uploading, configuration and administration of applications, sending transactions to a distributed ledger, and the querying of application metadata and ledger data. The REST API is primarily used for interactive clients such as web, mobile, and bot applications.
The following patterns describe the aspects of the REST API that send transactions to a distributed ledger and those that query data about transactions from Azure Blockchain Workbench’s off chain SQL database.
Sending data into a distributed ledger
The Azure Blockchain Workbench REST API provides the ability to send authenticated requests to execute transactions on a distributed ledger.
This occurs using the process depicted above, where:
- The external application authenticates to the Azure Active Directory provisioned as part of the Azure Blockchain Workbench deployment.
- Authorized users receive a bearer token that can be sent with requests to the API.
- External applications make calls to the REST API using the bearer token.
- The REST API packages the request as a message and sends it to the Service Bus. From here it will be retrieved, signed, and sent to the appropriate distributed ledger.
- The REST API makes a request to the Azure Blockchain Workbench SQL DB to record the request and establish the current provisioning status.
- The SQL DB returns the provisioning status and the API call returns the ID to the external application that called it.
Querying data from a distributed ledger
The Azure Blockchain Workbench REST API provides the ability to send authenticated requests to query details related to smart contract execution on a distributed ledger.