I wanted to do some testing to make sure the application would reliably process messages from 1000’s of devices…
The first thing I learnt was “don’t forget to restart your Azure Function after deleting all the devices from the Azure IoT Hub” as the DeviceClients are cached. Also make sure you delete the devices from both your Azure Device Provisioning service(DPS) and Azure IoT Hub instances.

The next “learning” was that if you forget to enable “always on” the caching won’t work and your application will call the DPS way more often than expected.

The next “learning” was if your soak test sends 24000 messages it will start to fail just after you go out to get a coffee because of the 8000 msgs/day limit on the free version of IoT Hub.

After these “learnings” the application appeared to be working and every so often a message would briefly appear in Azure Storage Explorer queue view.

The console test application simulated 1000 devices sending 24 messages every so often and took roughly 8 hours to complete.

In the Azure IoT Hub telemetry 24000 messages had been received after roughly 8 hours confirming the test rig was working as expected.

The notch was another “learning”, if you go and do some gardening then after roughly 40 minutes of inactivity your desktop PC will go into power save mode and the test client will stop sending messages.
The caching of settings appeared to be work as there were only a couple of requests to my Azure Key Vault where sensitive information like connection strings, symmetric keys etc. are stored.

Memory consumption did look to bad and topped out at roughly 120M.

In the application logging you can see the 1000 calls to DPS at the beginning (the yellow dependency events) then the regular processing of messages.

Even with the “learnings” the testing went pretty well overall. I do need to run the test rig for longer and with even more simulated devices.
I think this should do

If you get lots of errors in the logs “Host thresholds exceeded: [Connections]…. might need to bump your plan to something a bit larger