问题
I have the following setup:
- Multiple modbus sensors
- 1 Gateway connected to these sensors via ModbusTCP. On this gateway, one Azure IoT Edge module is running (using the NodeJS SDK), that reads all values of each connected sensor
- Azure IoT Central for device management
In IoT Central, I would like to represent each modbus sensor with a separate device template. This way, I can configure dashboards that are unique for each sensor. These sensor device templates should then be configured to be child devices of the device template for the gateway. So one device template for the gateway and one unique device template for each modbus sensor. This way, I can provision multiple gateways with a different sensor setup without the need of creating a new device template for each of these gateways (I would only need to configure a different amount of child devices for each gateway).
The Azure IoT Edge modbus module running on the gateway should then read all values from each connected sensor and send them to the IoT Central instance in the name of the sensor, so it looks like that the sensor had sent this message. However, I am not sure on how to implement this behaviour inside my Azure IoT Edge module.
The documentation states that this behaviour can be implemented (IoT Edge gateway device connected to downstream devices with identity provided by the IoT Edge gateway), however I could not find any documentation on HOW to implement this. I hope someone can help.
回答1:
The short answer is: there is no native support in the Azure IoT stack that supports that scenario. The documentation you have linked to has been under discussion for a while now and a feature request has been created. That doesn't mean it's impossible though, but it involves some workarounds that might not be acceptable to your use case.
One way to provide identity to your sensor is to create a device for each sensor in IoT Central and to pass their connection information to the module twin of a module you need to build. That module would receive the sensor values, figure out what connection information to use and send telemetry straight to IoT Central (so not through the Edge Runtime).
Update: Microsoft created a sample module that shows how to provide a basic implementation of identity translation. Other than that, no native support in the runtime yet.
来源:https://stackoverflow.com/questions/62654740/azure-iot-edge-module-identity-translation-for-virtual-downstream-devices