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.

Henri Dethier of Microsoft at the meetup in Zurich

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.

Azure Blockchain Workbench architecture for IoT (Image credit)

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.

“Thanks to the Blockchain Workbench, you can do a proof of concept (PoC) in a matter of weeks from nothing to having the PoC running. Then, you can do a lot of use cases, and you can understand business value. You can accelerate the cycle compared to other big projects, which after 2–3 years are going nowhere.” —Henri Dethier, Microsoft

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.

Connecting IoT devices to smart contracts (Image credit)

“To integrate, we have the Development Kit. It helps you to connect to interfaces, integrate to your ERP, hash documents, and implement IoT scenarios. It’s something that we’re going to extend.” —Henri Dethier, Microsoft

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.

A sample workflow for a refrigerated transportation app (Image credit)

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.

“In case the transport conditions go bad at a certain point in the supply chain, you’re going to see a spike in the data. This spike will put the smart contract in an out of compliance state.”
—Henri Dethier, Microsoft

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.

Configuring the Azure Blockchain Workbench (Image credit)

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.

The smart contract checks for humidity and temperature (Image credit)

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.

Defining a new smart contract (Image credit)

“The great thing about routes is I can not only use that to help route data to the blockchain, but we can also make sure that if we want to do analytics across all the sensor readings coming in, we can go ahead and send all those to a secondary off-chain data store.”
—Marc Mercuri, Microsoft

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.

Logic Apps parse raw data in JSON (Image credit)

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.

“We have a Logic App that’s checking different pieces of information coming in, and then within Logic Apps, they have a number of different connectors that you can go ahead and plug in here. We’ve got Office 365 sending an e-mail, we have a partner named Twilio that has an SMS interface, and we also have another one down here, which is an Azure function that wraps another type of modality, which is voice.” —Marc Mercuri, Microsoft

A Logic App can send real-time alerts (Image credit)

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.

 

Want details? Watch the videos!

Table of contents

  1. What are the challenges of building a blockchain application? (0’28”)
  2. What is the Azure Blockchain Workbench? (4’17”)
  3. What services come with the Azure Blockchain Workbench? (7’24”)
  4. What is the Azure Blockchain Development Kit? (9’50”)
  5. Demo: refrigerated transportation (15’15”)
  6. Questions and answers (28’26”)

 

These are the slides by Henri Dethier presented at the meetup in Zurich.

 

Here, JT Rose describes the scenario of an ice cream retailer tracking metrics during transportation—from a farm to manufacturing to a store.

 

In this tutorial, Marc Mercuri demonstrates how to use smart contracts to create a supply chain application for an ice cream retailer.

 

Further reading

 

About the experts

Henri Dethier is Technology Solutions Professional at Microsoft focused on Azure apps and infrastructire. He is also involved in other initiatives around blockchain and cryptospace to drive mass adaption. Henri is a member of the master network, Quantitative Techniques for Economics and Management (QTEM), specializing in finance.

 

Marc Mercuri is Principal Program Manager at Microsoft. His career has included architecture, consulting, engineering, evangelism, and strategy leadership roles at startups, enterprises, ISVs, and CSVs. Marc has worked in Europe, Latin America, Asia, and the United States. From this experience, he brings an entrepreneurial perspective and an ability to work across the business that has been recognized by multiple awards from engineering, evangelism, and sales organizations.

 

JT Rose is Senior Product Marketing Manager at Microsoft where he works with a team of engineers to build and scale the company’s blockchain business. He leads product marketing and growth for the blockchain offerings of Microsoft, working across product management, commercial strategy, and market execution. JT is also involved with the Azure Blockchain blog.

The post is written by Carlo Gutierrez and Alex Khizhniak, with assistance from Sophia Turol.