I am using Azure Functions consumption plane and Azure durable Function for IoT device Status change monitoring. Once I optimise my code, I will be updating my plan to either service or premium.
An individual durable function is executed from time to time. The purpose is to instruct an IoT device to perform a certain operation and then to monitor its status till the operation is completed. The duration can be between 5 to 20 min. Every 10 seconds or so, the durable function would check the status and then go to sleep using the following code:
if (iotstatedata.sleepduration > 0)
DateTime deadline = context.CurrentUtcDateTime.Add(TimeSpan.FromSeconds(iotstatedata.sleepduration));
await context.CreateTimer(deadline, CancellationToken.None);
This would be done for each IoT device.
This has been working well, but recently the CPU consumption of Azure Function reached 90%, and something went wrong where the Azure Function App either restarted or was closed. This resulted in my Durable function being abruptly stopped, with my IoT device set into operation, which was never completed.
Has anyone experienced durable function operation stopping like this?
Just out of curiosity, every time the durable function wakes and sleeps, does that increase the CPU usage toward a high value?
Instead of having a separate durable function instant for each IoT device, is it better to handle multiple device operations in some type of batch? For example, send 10-20 IoT device instructions and then check them all one after another at the same time.