These Azure Functions are to be used as examples to process ingested data as well as twin updates. It assumes you have already set up your Azure Digital Twins instance with ingress and/or egress steps completed.
For instructions on creating an Azure Digital Twins instance and setting up data ingress and egress, see the following articles:
This function is used to process data as it is ingested into Event Hub and then sets the property values of the device twins in Azure Digital Twins. In this instance, the messages come from devices in IoT Hub that are used to track temperature and humidity values.
- Each message contains humidity and temperature data. Temperature arrives in Celsius format, and needs to be converted into Fahrenheit.
- Humidity and temperature need to be rounded up.
- Devices are a 1-1 match to a room, we need to update the temperature and humidity properties for the associated room.
The outcome of this function is to get the average floor temperature and humidity values based on the rooms on that floor.
- Get the incoming relationship of the room. This will get the floor twin ID.
- Get a list of all the rooms on the floor and get the humidity and temperature properties for each.
- Calculate the average temperature and humidity across all the rooms.
- Update the temperature and humidity properties on the floor.
See Connect an end-to-end solution in the Azure Digital Twins documentation for more information about publishing an Azure function to work with Azure Digital Twins.