IoT with MS Dynamics 365 Business Central on Azure

IoT with MS Dynamics 365 Business Central on Azure

Is it possible to have real-time information about the filling of a silo in my ERP System? A common IoT task, where sensors provide information about almost everything. This use case sounds good for me to repeat, what I have learned during the IoT Workshop with Microsoft at COSMO CONSULT.

What can I use for this demo? A couple month ago, I visualized a Silo in Dynamics 365 Business Central. The creation of the Control Addin and the Extension v2 was quite fast with VS Code and Microsoft AL. As demo for an industrial silo I could use my water tank of my tomatoe watering system. This should work too.

Getting Started in 5 Minutes

Sounds crazy but this is possible, when everything is prepared! Let’s start with the hardware. In my case, I started with the device I’ve got during the workshop last week (ESP8266 with a sensor). Meanwhile, I learned, it doesn’t matter which device is used! Because there is a plenty amount of chips, boards and mini computers with sensors to collect data. 

Is this a challenge? My conclusion, the Hardware is not the issue. Except, you wait until your device will be delivered from the other side of the world.

Setup the IoT Device in Azure

What do we need? An IoT Hub which work as an endpoint for my IoT Device. Well this task was done very fast! I used my Azure account and created an IoT Hub.

After provisioning I added a device to the created IoT Hub and copied the Device Connection String for my next steps.

Setup the Hardware

What’s about programming the hardware, this seems a little bit tricky. Good news for us, there exist lots of tools, demos and tutorials to do this. The important steps are:

  • Connect the sensor with your device (Read the manual and find the right pins)
  • Find an IDE to program your device (I’ve used e.g. the Arduino IDE)
  • Configure your IDE to communicate with your device. This means e.g. load the needed libraries, select a COM Port and so on.
  • Use a program skeleton or customize an existing demo.
  • Use your Wi-Fi information and the IoT Hub Device Connection String in the device code
  • Compile and Deploy – the Setup of the device is done!

This part was a little bit tricky for me. However, I got my hardware connected. In the real live there are colleagues at COSMO or other experts who can help.

Together with my friend Toni, we made a brief video about the fast setup of a IoT device with Azure and a Dynamics 365 Business Central (Docker Sandbox):

Use the Device Data

What’s next? We have an IoT device sending some data to our IoT Hub in Azure. These data can be processed by Azure Stream Analytics. Another component in Azure was provisioned into my Resource Group.

Azure Stream Analytics

Azure Stream Analytics tells us already, what we can expect from this technology. It allows us to analyze a stream of information by using a special Query Language. In my case, I take all the data to see a quick result in my Business Central! Therefore, I take the entire input stream and route it to my output stream. The target of the output stream should be Business Central.

Mission “Output Stream for Business Central”

There are many ways to do it. One of the fastest is to add a WebService in Dynamics. For Business Central, this can be done with Microsoft AL and an Extension v2.

  • Add a Codeunit with a public procedure
  • Add a XML file which register the Codeunit as a WebService
  • Create a Web Service Access Key for your user

After the Extension is deployed and installed on Business Central, we can use an Azure Function to call the WebService. The steps depend on which kind of Azure Function you will use. In my case, I have used a C# Project, added the Service Reference … so on and finally deployed the Azure Function into Azure.

The IoT data for the WebService of my Extension v2 are provided as a text parameter which contains JsonThe new Object Types for Json in Microsoft AL helps a lot to get the information out of the received parameter into a table. This is daily business.

Check and run the Stream Analytics Job!

Summary

With this few components and steps, it was possible to bring live data from my IoT Device into my Business Central. I removed a “Blind Spot in my Business”. What I can do with this information – yes and obviously this depends on my needs.

In the example, I visualized the filling of a Silo in the ERP System without manually adding information to the system. I got a real-time view of the content of an inventory location, a common use case for a manufacturing company.

Such data can be used for tasks like … Well I’ll work on this after my vacation!

Share

Leave a Reply

Your email address will not be published. Required fields are marked *