Hi Pietro
I'm glad that your issue is resolved and thank you for posting your solution so that others experiencing the same thing can easily reference this!
Since the Microsoft Q&A community has a policy that the question author cannot accept their own answer, they can only accept answers by others, I'll repost your solution in case you'd like to Accept the answer.
Error Message:
Solution:
Azure Support adviced to use IoT Central Device Bridge to hide registration/re-assignment of devices under the hood. What actually is good idea.
Note, that mentioned IoT Central Device Bridge has the following logic:
- Try to get device connection string from local cache
- if connection string exists, use it to send telemetry to Azure IoT Central
- If connection string does not exist, register and assign to new IoT Hub device. Take into account that Azure Function is not "warm" forever. If you don't use it for several minutes it becomes "cold" and local cache will be lost. It means that next time you send new request, a device will be re-assigned to new IoT Hub. It maybe not very big problem from functional point of view, but it take additional time, so performance is definitely effected
I have to make improvements to have the following logic:
- Try to get device connectiion string from local cache
- if connection string exists, use it to send telemetry to Azure IoT Central
- if connection string does not exist, try to get assigned hub
- if assigned hub received, use it to send telemetry to Azure IoT Central
- if device does not have assigned hub, register and assign it
- If sending of telemetry is failed due to ENOTFOUND, force re-assignment of device
If you have any other questions, please let me know. Thank you again for your time and patience throughout this issue.