PowerAzure365

View Original

Dynamics 365 Azure IoT - Industry 4.0

Hello the Community !

A new article for you now about something I was working at Dynagile for some time now with couples of EMEA projects / especially on D365 Finance Operations => all about IoT ! As usual with me ! My favorite topics with Azure components with Dynamics 365 (Field Service, Customer Service and Finance Operations) - business side to leverage Data Insights with Microsoft technologies all combined, as part of Industry 4.0 concept - let’s go !

Indeed, Industry 4.0 is the concept of the factory of the future…

Couple of years ago, it was still a concept, now, it’s a reality!

Many manufacturers want to leverage data coming from IoT to take some actions automatically and also predict some behaviors. IoT is an old service, well by old I mean a couple of years now :)

And of course, when I talk about Manufacturers, I will speak about Microsoft technologies and by that, Dynamics 365 and Power Platform integrations. While it was great to put in real time some data coming from IoT in Azure, it was still a concept to put it in your ERP / CRM architecture, as part of Dynamics 365 platform. Now, you will see that Microsoft has created some setups and direct integration without coding somethings in between.

Azure IoT hub is agnostics of the hardware, meaning you can connect (online and offline mode) any kind of data: temperature, humidity, signals in general.

Source : Microsoft Cloud Blog

Azure IoT Hub can connect to multiple endpoints, enrich data and route them. In case of Dynamics, it’s often the custom built-in endpoint you will pick.

Of course, for BI and ML, I will pick the route D here below, to push it into a Data Lake Storage to “cool/achive” - the hot path will be the one below on top.


For the first topic, I will jump first on the ERP system of Microsoft : Dynamics 365 Finance and Operations.

Also since I just hold in home 1 Raspberry PI but with no sensors on it, I’ll pick the simulator that everyone can use any time to test or do some demonstrations: I recommend it for sure :)

Raspberry Pi Azure IoT Web Simulator (azure-samples.github.io)

As you can see below, you will be able to modify the NodeJS code, and you have temperature and humidity sensors, that will simulate capturing data every 2 seconds, and push them to an Azure IoT Hub. Of course, if you want you can still buy a real one and connect everything, you have a lot of tutorials to setup it with Azure inside. (Windows 10 IoT Core) - but don’t forgot to buy sensors otherwise, it’s useless :)

So going back to Dynamics 365 Finance Operations now, Microsoft love to put new stuff via Micro Service Architecture (aka LCS Addin)

They have released 1 year ago a new Addin called: IoT Intelligence. I would suggest for you to ge there if you want to learn lot more (in details) :

This is the topic I will explain to you now. So first, since we talk about LCS Addin, there is a new requirement now. You MUST install and set up a Power Platform integration with a TIER 2 instance. And yes this Addin works only for TIER2 or higher.

OK before jumping to the configuration, let’s talk a bit more about this Addin.

IoT Intelligence is an add-in for Microsoft Dynamics 365 Supply Chain Management. It integrates IoT signals with data in Supply Chain Management to produce actionable insights.
As of today (April 2021), we have 3 OOTB (Out of the Box) scenarios :

  1. Product delays : compare actual cycle time to planned cycle time of production => avoid order delays

  2. Equipment downtime : my favorite one, compare measured uptime to user-defined parameters. You will be notified when an outage threshold is exceeded. Create maintenance work order (maybe also directly in Dynamics 365 Field Service) - rescheduling production work order.

  3. Product quality : For Raspberry simulator where you put temperature and humidity data, this scenario will read those sensors and notify you when a deviation occurs. Maintain quality standards and minimize waste !

Source : Microsoft Documentation

So now let’s do some configurations :)

And like usual now with Micro Service Architecture, you will need to go to your Azure Subscription tenant. (same as your Dynamics 365 FinOps instances)

Let’s double check if you have already this Enterprise Application in your Azure AD tenant : “Microsoft Dynamics ERP Microservices”

If not, you can add it by the Azure Cloud Shell with a Admin Account :

  1. In the Azure portal, on the toolbar, select the button to open Azure Cloud Shell.

  2. Run the command Install-Module AzureAD. Enter Y to install the module.

  3. Run the command Get-InstalledModule -Name "AzureAD" to verify that the module is installed.

  4. Run the command Connect-AzureAD -Confirm to run the authentication.

  5. Run the command New-AzureADServicePrincipal -AppId 0cdb527f-a8d1-4bf8-9436-b352c68682b2.

If you don’t have a Key Vault, you should ! Globally, every authentification and security are using now this component on Azure.

So, let’s create one if you don’t have it.

Create 2 more components now, Azure IoT Hub and Azure Redis Cache - don’t change anything on this part, just choose all defaults parameters. Of course pick an Azure Resource Group close to the same location of your Finance Operations TIER2 instance.

Azure Cache is here to close the loop between IoT and the Micro Service. The Micro Service will read IoT Hub with consumer groups, push it to the cache and Dynamics will read this cache. Cache is all in memory concept, giving real time access.

So now you have all needed. Few more setups are required.

Like below, you have to put the Micro Service App into Access Policy of your Key Vault (Get/List)

In the Secrets part, you have to put 2 ones, one for the connection string of the EventHub attach to your IoT Hub and one for the connection of the Redis Cache.

For IoT you can pick it here , in “EventHub compatible endpoints” - You will notice that I have created 3 more Consumer Groups like below, “microsoft.dynamics.iotintelligence-X” - 1, 2 and 3 : it’s required for the micro service LCS addin to read the data from IoT Hub.

Now your Key Vault is OK. You can still go to your IoT Hub to recreate as many IoT devices you want. On my side, I have created one to map the Online Simulator I talked before.

Let’s go to Dynamics 365 F&O now, in LCS first,

You should be able to install the Addin now like this :

When it’s OK, go the TIER 2 instance in Feature Management workspace, to activate the flag feature for “IoT Intelligence” :

Go the Production Control Module now, and you should find the Scenario Parameters menu item (completely at the end)

Copy/past the Azure Cache Redis Connection Parameter here in Time Series.

In Equipment downtime, you can put machine/resources with any kind of threshold

In Product delays, you can put notification threshold for delay in term of percantage by route / item / operation of production - configuration

Now go the production control module again and check those menu items :

Go to “Metric Keys” and Click Update. I would recommend here to put as a Batch processing for every 5 minutes

When IoT Hub will receive data, micro service will put automatically in Azure Cache, and Dynamics needs to see those metric keys to enable scenario.

In Notification hub, business users can check automatically notification from IoT - close or dismiss it. Here is where you can create a maintenance production work order based on that. If you have Dual Write activated, this can create a case or a work order for a technician available and near the factory !

Now you can activate scenarios in “Scenario Management”

I will pick as a demonstration Equipment downtime series, but all are very similar as term of setup

Here you will have first as Wizard, put your schema data contract : here this is the most simple one : ID (identifier) , UNIX timestamp, and Value : True or False here.

Here I am mapping the machine ID name from IoT to my machine in Dynamics 365 FinOps (as a resource : WrkCtrTable)

Here I am mapping the value, important is to say OK when the signal data value will TRUE , all is fine, otherwise, well it’s not fine :)

Last but not least, the threshold setup in order to check it for a downtime more than 5 minutes. Of course, you have to enable your scenario. Here I wanted to put it because one thing important : when you modify your schema / path you should disable it first and enable after your change.

Now we are good to go !

Let’s go the Raspberry Simulator. Don’t forget to put your Azure IoT Hub Connection String

You can see I have change the function GetMessage to put the same schema I wanted to Dynamics 365 Finance Operations.

Of course you can do it what you want

See this content in the original post

One more thing about Dynamics, you can have a dashboard to see 1 specific machine by going to this Menu Item : ?cmp=USPI&mi=IoTIntMfgResourceStatus

You can pick Value by TimeStamp or Temperature by Timestamp


And this is not finished :)

Since all my DATA are now on Azure about my IoT Devices, let’s go further on data analytics.

First, I will create a Stream Analytics Job to push in real time my Data to PowerBI

Very simple; I don’t change a lot of things, just mapping an input from IoT Hub and output as PowerBI Dataset, without any transformations between, but it could be possible of course !

After you can create a report based on the real time dataset of PowerBI, and pin it into a Dashboard where you will see the data (like temperature in real time)

Second, I will also like I said before in this article, put everything in a cool storage : my Data Lake

The same Data Lake connected to my Dynamics 365 F&O instance, I will create a new specific folder called IoT in top folder root.

This can be done in IoT Hub here in the Message Routing, add a Storage account (your Data Lake)

In my Data Lake here :

And yes it’s an .AVRO file type, perfect for the integration after in my same Synapse Analytics / Modern Data warehouse as Dynamics 365 or Power Platform data.

And last of course, after integration in Synapse, I can cross data because all my DATA are in the same data warehouse, but not only, I can go deeper with Machine Learning to prepare a global dataset to predict behaviors, when I will have enough DATA from my IoT Devices.


Finally, let’s go for Dynamics 365 Customer Service + Power Platform

This feature is called : “Connected Customer Service”

Connected Customer Service enables organizations to transform their service model into a proactive and predictive service model with the availability of IoT diagnostics, IoT device update, and case management on one platform. Agents using Customer Service Hub can diagnose and fix issues remotely, which leads to cost savings and improved customer satisfaction.

Key benefits of Connected Customer Service:

  • Reduce downtime by connecting to IoT devices to diagnose problems before customers are aware of an issue

  • Address issues faster by remotely monitoring and updating devices and keeping customers in the loop

Here is the architecture below with Azure IoT Hub (the same as I used for Finance Operations)

Source : Microsoft Documentation

Well here, I will change a lot of things for me : the path for BI, I will pick my architecture I explained before… :) and for IoT Hub yes why not with Stream Analytics from an EventHub/ServiceHub when a fault occur - and yes why not Logic Apps, but you could use Power Automate too :)

Hum, because I love to show that everything is related, I will add one more path in case you have Dynamics 365 Customer Insights with the Real Time API with a Logic App . And yes IoT Data is any case a rich value data to add to your Customer Data Platform (CDP) : all in one place !

Source : Microsoft Documentation

In case, you have Customer Service directly mapped to a Field Service App of Dynamics 365, you can also leverage that and assign a work order to a technician based on that : it’s called : Dynamics 365 Connected Field Service.

And don’t forget that everything can be added into a Dataverse environment - global part of those Dynamics 365 apps, and add any kind of Power Automate flow (e.g trigger it when IoT alert, direct message to a Microsoft Teams channel, well pick whatever example you want on any kind of 450+ connectors, as well as creating very fast a Power Apps to show Data IoT alerts into a Surface Hub in the Factory : Pro Code to Low Apps Path here we are again ! :)

And because I loved this Live Demo from Microsoft, here we go (and don’t forget it was already 2 years ago !)

Hope you like it, feel free to share, and feel free to contact me/us at Dynagile if you want to leverage your Azure IoT Data with any kind of Dynamics 365 apps / Power Platform !

I will prepare also a Youtube video very soon to show you that in LIVE DEMO as usual !

Aurelien