Valeria Vishevataya in InternetOfThings (IoT), IoT, BLOCKCHAIN Community Manager • Altoros Apr 24, 2019 · 3 min read · ~100

IoT Meets Blockchain: Building a Supply Chain App on Microsoft Azure

Originally posted on

IoT Meets Blockchain: Building a Supply Chain App on Microsoft Azure

This article highlights how to deliver IoT apps for a supply chain—tracking humidity, temperature, etc.—with Azure Blockchain Workbench and Development Kit.

Challenges in developing blockchain projects

When enterprises start adopting blockchain, typically, there arise problems from understanding blockchain itself to building an application. While blockchains can be associated with DApps, smart contracts, consensus mechanisms, ledgers, tokens, and shared business processes, not all blockchain applications require all of these things.

Once an enterprise figures out what it wants with blockchain, the next step is developing an application. This phase has its own challenges, which include writing business logic, integrating with existing business systems, configuring the consortium network, managing keys, storing smart contract reference data, etc.

In case of creating an app for the Internet of Things (IoT), one has to deal with telemetry—managing and processing data which arise during operations. In a supply chain, all of the mentioned technologies may meet. As a result, “what we typically see with customers is that they want to do a blockchain project but don’t know where to start,” as noted by Henri Dethier of Microsoft at a recent blockchain meetup.

While we previously covered what blockchain can bring to IoT in terms of security, this article explains the technical side of addressing the challenges associated with implementation. Exploring Azure Blockchain Workbench and Azure Blockchain Development Kit, it exemplifies the process of creating two IoT-driven apps on a blockchain. The scenarios include refrigerated transportation (monitoring humidity and temperature), as well as a similar one for an ice cream retailer.

Azure tools available for blockchain

To foster the process of building and deploying a blockchain app, there a couple of tools and services from Microsoft on the Azure platform/marketplace. In particular, the Azure Blockchain Workbench was designed to help developers focus on writing business logic and smart contracts—by providing an infrastructure necessary for a blockchain.

Technically, according to Henri Dethier, “the Blockchain Workbench is a template, which is software-defined in the cloud. It has different resources, and it has all the capabilities of a blockchain application out of the box.” One of the scenarios of using the service is creating IoT apps on a blockchain.

REST APIs and message-based APIs provide an interface for users to replace or exploit multiple blockchain technologies, storage, and database solutions. Data on a blockchain can be automatically synchronized with an off-chain storage, making it easier to analyze events and telemetry information collected.

On the other hand, Microsoft has the Azure Blockchain Development Kit, which contains samples for integrating, connecting, and using DevOps to interact with a blockchain. It incorporates Azure services for key management, off-chain identity and data, as well as for monitoring and messaging APIs.

During the meetup, Henri explained how to make use of both technologies for refrigerated transportation.

Example #1: refrigerated transportation workflow

In this scenario, a smart contract employs IoT devices to monitor and track the provenance within a supply chain (such as the origins of bananas imported). The supply chain must adhere to specific compliance rules, such as minimum and maximum values for humidity and temperature. Should either humidity or temperature fall out of the acceptable range, the contract changes its status to out of compliance. With this approach, one can monitor whether the food is delivered in a good condition or it was stored inappropriately (and where this happened).

According to Henri, in this supply chain, the details of the contract are always publicly visible to all participants. During transportation, the current counterparty holding the cargo specifies the next counterparty responsible. This information along with the temperature and humidity data gets written to the chain, enabling the supply chain owner and any supply chain observer to figure out which counterparty is liable, should the contract’s status go out of compliance.

This diagram illustrates all the possible changes to the state of the contract, as well as the transition functions at each state. It also indicates when telemetry data is collected, and how contract specifics are enforced, should there be any humidity or temperature issues during transportation. 

The source code for this demo can be found in this GitHub repository. Watch the video below to see how the scenario was implemented by Henri on Azure.

Example #2: an ice cream retailer app

In the Microsoft Mechanics series, fellow colleagues of Henri demonstrated how to create a similar app for an ice cream retailer. The first video describes the scenario itself, with JT Rose of Microsoft explaining how to access the the Blockchain Workbench on the Azure Marketplace and use the wizard to configure the software and services.

With the Workbench ready, smart contracts can be uploaded. In another tutorial (more technical one), Marc Mercuri of Microsoft demonstrates how to implement a smart contract including definitions for roles, properties, and functions needed by an ice cream supply chain.

With the smart contracts configuration in place, new contracts can be created to monitor telemetry data, such as humidity and temperature. Once a contract is created, it’s up to sensors to collect and send data to Azure IoT Hub. This data can be filtered through routes, so only those that fall out of compliance are sent in.

Since the IoT sensors are sending in raw data, Azure uses Logic Apps to parse this into a JSON file, which the Workbench can read.

Finally, triggers can be created using a Logic App, which can send real-time notifications, should there be any non-compliance issues anywhere in the supply chain.

By using the tools like those available on Azure, organizations looking to experiment and adopt blockchain can quickly build PoCs without having to worry about the underlying infrastructure. In addition, one can also utilize the templates available to learn about common scenarios and eventually build their own blockchain applications. While a couple of years ago a combination of IoT and blockchain sounded just like another promising idea, now we see that real-life scenarios appear with technologies already available to implement the necessary workflows.