Azure IoT Edge: How to monitor the edge module (install) state for all devices on IoT hub - azure-iot-hub

Is it possible to read events from IoT hubs in a way that we receive all status changes for IoT edge module installs? Possibly by receiving state changes to the edge agent reported properties of all connected devices?
Background: We are allowing users to "install" applications (represented by edge modules) on their edge devices on the fly through our own portal. We want to monitor changes to IoT devices and their modules, and note the changes in our database, so we can flag the corresponding apps as installed, removed, or failed.
Right now I can only find Event Grid based events for Device connected / disconnected events. I can also see that I can manually query the desired properties of each edge device's edge Agent separately. But since we will a large number of edge devices connected (>5000), polling them all just to see if something changed is not feasible.
Are the edge agent status changes of all IoT edge devices available as an event stream somewhere? Or is there a better solution?

IoT Edge's integration with Azure Monitor may help (docs). It has a module view that shows which modules are running and their availability. Since all the data is available in Log Analytics, you can create custom visualizations and processes using the data.

The Module twins in Azure IoT Hub shall help in below based on the information stored with it.
Monitoring the connectivity of the system
Monitoring the health of IoT Edge deployments
The Azure IoT Edge runtime has "IoT Edge Agent" as one of two modules that performs installation / initiation of modules and updating / reporting of the status of the modules to the IoT Hub. The $edgeAgent maintains the health and connectivity data about both the IoT Edge agent and IoT Edge hub runtime modules.
The Azure IoT Edge hub runtime maintains the data about communications between the "IoT Edge hub" running on the device and that of Azure IoT hub via the $edgeHub.
High level Overview :
Here is "Azure Monitor workbooks for IoT" that provides views couple of views :
An overview / state of active devices can be seen in the "Devices" View
Alerts display as per rules configured for the devices in "Alerts" View
Azure Monitor workbooks can be tuned for seeing data at any level (device state, app status) of interest. The public templates can be modified to meet the need/requirement in hand. The data shall fetched based on resource-centric KQL queries on the InsightsMetrics table.
Screenshot of Devices View :
Screenshot of Alerts View:
References :
Monitor Module Twins
Monitor Workbooks

Related

Send and receive iot-hub messages

I am working on a project based on the azure sphere kit where I want to control a motor from a web application. I managed to send the command to the iot hub and the build in monitor shows that the message is received by the iot hub. Now, my question is: How can I forward this message to the board? I have to mention that this is my first experience with the iot-hub so please dont judge me if it is a stupid question.:) Here is the confirmation that the message is received by the iothub
If you want to communicate with your Azure Sphere from Azure IoT Hub, you're talking about Cloud-to-device communication. There are three different ways to do this communication:
Direct Methods
Device Twin Desired Properties
Cloud-to-device (C2D) messages
Microsoft documented them here. This document also lists the different considerations for each of the three methods.
To forward the IoT Hub message that you mentioned in your question, a good start would be to write an Azure Function that listens to the IoT Hub output and send that to the device using one of the three methods above. You can find an example for the Azure Function IoT Hub trigger here
Adding few more detailed options in this scenario to the above responses.
Scenario 1: You may be interested in configuring your devices from your back-end service(s) as your web application. To synchronize state information between a device and an IoT hub, you use device twins. A desired property is set by a back-end application and read by a device. A reported property is set by a device and read by a back-end application. A tag is set by a back-end application and is never sent to a device. You use tags to organize your devices. Long-running commands intended to put the device into a certain desired state. For example, set the telemetry send interval to 30 minutes. This completes your E2E state synchronization scenario : Web-Application<=>IoT Device, Ref Link
Question: How can I forward this message to the board?
Scenario 2: You may be interested in direct method to control a device connected to your IoT hub. You can use direct methods to remotely change the behavior of devices connected to your IoT hub. Commands that require immediate confirmation, such as turning on a fan.
Requirements:
-->IoT Device: To receive the direct method calls, the applications running on IoT Device connect to a device-specific endpoint on your IoT hub.
HostName={YourIoTHubName}.azure-devices.net;DeviceId=MyNodeDevice;SharedAccessKey={YourSharedAccessKey}
-->Web-Application: To call a direct method on a device, your Web application connects to service-side endpoint on your IoT hub.
HostName={YourIoTHubName}.azure-devices.net;SharedAccessKeyName=service;SharedAccessKey={YourSharedAccessKey}
Direct Method calls: Points to be noted. Please visit the link: detailed comparison of the various cloud-to-device communication options.
The maximum direct method payload size is 128 KB.
Disconnected devices are not contacted. The solution back end is notified that the device is not connected.
Ref Link
If you need further help in this matter, please comment in the below section and we will be happy to help you on this forum.

Access control of Azure IoT Edge device management

Is it possible to restrict management of IoT edge devices by groups or some filtering criteria?
The scenario would be that we have different sites with different edge devices deployed to these sites. We have a single IoT hub for the organization, is it possible to restrict management of only certain devices within the IoT hub or would we require different IoT hubs by site to do this?

Is there a way to connect the data present in Azure IOT hub to IOT Central smart meter application

I have published data to the Azure Iot Hub devices from my hardware devices. Now I want to perform some analysis using the IOT Central's application 'Smart Meter Monitoring' the link to the website is this https://apps.azureiotcentral.com/build/energy.To be more concise, I'm trying to consume the data present in the azure iot hub devices using the the IOT Central's application 'Smart Meter Monitoring' so that i can build dashboards on the data that is consumed. I Have browsed many websites and I am not having any progress in trying to connect azure IOT HUB and the 'Smart Meter Monitoring' application of IOT central. I am beginner in this field want to understand how this integration is made any tutorial or blog will be helpful
You could use this repo https://github.com/IOTD-Americas/iothub-bridge-function in order to re-send all telemetry from IoT Hub to IoT Central using an Azure Function in real time

Azure webhook triggers a IoT Hub

I want to make a webhook that can be triggered by either get/post and triggers connected IoT devices to a WebSocket.
So, I thought Azure might help to automize this process, instead of writing everything from scratch and run it on a webserver.
I am very new in the Azure world, I found it very complicated to make it working on Azure.
Can you point me to any simple to make it work?
The first thing to do is to decide where you want to connect your devices to. Generally, you'll either use Azure IoT Hub or IoT Central (which uses an IoT Hub anyway). Your question doesn't include any details about your devices, or whether you're developing them yourself, but I'll assume you can connect to either.
If you go for Azure IoT Central, the easiest way to get a webhook going is to create a Logic App and link nodes together to trigger a Command to your device. You can use an HTTP request as the trigger, and use the built-in IoT Central node to trigger your command, example:
If you end up connecting your devices to IoT Hub, you can use Direct Methods, Cloud to Device messages or even Device Twins to communicate with your devices. You can leverage these by creating an Azure Function with an HTTP trigger, and you program the logic to call IoT Hub, which will communicate with your devices. There are a lot of samples on the web that show how to create Functions, or control your device remotely.
There are a lot of ways to go about your scenario, if you need some help from the Microsoft community, you can get a lot of help on Microsoft Q&A.
Update based on the comments:
In this case, the devices are connected to IoT Hub. You can use the Service SDK to run a job that fires a Direct Method to all currently connected devices. This doc describes the process.

Azure IoT Hub Device Identity requirements

I need to connect some sensors to an Azure IoT Edge Runtime via MQTT.
I read here:How an IoT Edge device can be used as a gateway , that in the "Transparent" Pattern, devices who hold their own IoT Hub device identity can communicate directly with Azure IoT Edge via MQTT.
I am still in the planning phase and don't have the sensors (or Iot Hub devices) at the moment so I couldn't really start testing directly. I wanted to know if all devices/sensors can hold their IoT Hub device identity and if there are any hardware requirements in order to do so?
Thank you very much in advance!
In the transparent gateway case, the requirements for devices / sensors are the same as if the device would connect directly to an IOTHub using its identity. That is, if the device or sensor supports to Azure IOTHub via MQTT, it should work through the transparent gateway. When configuring the device, instead of using a connection string for the Azure IOTHub itself, you'd use a connection string that references the local Edge gateway.
There are 3 basic steps to take in the transparent gateway scenario - the article you linked steps into them, but I'll add in some color for 2 and 3.
Set up the gateway for connectivity from the downstream devices & routing to the upstream IOTHub. This article has good details.
For each device, create an identity in Azure IOTHub, using the device's unique ID (for example, device EUI for a lorawan sensor) as the IOTHub DeviceId, and set up auth per this article. This step is where you determine the Edge gateway connection string.
Connect the downstream device to the gateway device and start sending messages. That's this article. This is obviously dependent on the device itself and the operating code/configs (whether a 3rd party black box type device or something running your own code).