we are using Interfax as our fax provider. We have an Azure Blob storage account, and a function triggered by new uploads. When we upload the blob the function is invoked, and this part works correctly. In fact most of the calls work correctly, however some get lost it appears.
After we send the fax we have a loop to check the status. After each status check we call System.Threading.Sleep(120000).
About 15% of these seem to get stuck. We traced the event and it seems as though it does not return from the sleep call.
Some information mentioned not to use System.Threading.Sleep in a .NET azure function.
Does anyone have any other suggestions on how we can resolve this issue, or even any other insight as to what might be going on?
Currently we try 30 times with a 2 minute sleep which means that some Azure Blob Triggered function could run for over an hour. Perhaps many parallel invocations could cause the issue?
Azure Function executions should be kept as short as possible, and well within the timeout limits. Timeout limits are different based on the tier/plan under which the Function app is hosted.
For your scenario, it is better to use one of the suggested ways for handling such long running logic. MS document. One approach could be to have a
durable functioncheck for the status, or even atimertrigger that checks the status of the Fax request every X min/seconds. If the fax provider gives callback(webhook) that would be more appropriate to use.