Hello @DataSciencentist2021 ,
if you followed that official tutorial, you should now have:
- deployed Azure IoT Edge on your device, connected to the IoT Hub
- ingest data into the database using input1 on the custom function module
- optional egress of data using output1 on the custom function module
If you want to send messages to the IoT hub, just route the output1 messages to $upstream. Or, use "FROM /messages/* INTO $upstream" to send ALL messages from any module to the cloud.
Once your messages arrive in the IoT Hub, you need to choose how to deliver these messages into a database (instead of that sync mechanism).
There are a few options, all starting with IoT Hub routing...
The short solution is to write an Azure Function triggered by the IoT Hub and write messages into the cloud database. Recently, there are new bindings made available for SQL Azure, these are still in preview.
A more elaborate and flexible way is making usage of an Azure Stream Analytics job. This way, you write an ASA query to eg. filter, aggregate, and transform the data without extra code. See this example on how to connect a database to Azure Stream Analytics.
Finally, because you are interested in devices being connected and disconnected, again IoT Hub routing is your friend. when a device is connected or disconnected, an event is created. Please check limitations and rules in the same documentation.
Keep in mind you need to check the message properties to find out if a device is connected or disconnected:
If this answer is helpful, please mark it as an Accepted answer. This will help others with a similar question.