@Anca Corbos Thanks for your patience on this. I am summarizing the offline investigations and posting the same answer for the benefit of other community members.
Issue: Azure Function took around 40 minutes to consume the message from storage queue.
Root Cause:
- During the specified time frame, we observed high CPU usage, which affected the function host's ability to execute background tasks like queue polling. Queue polling relies on asynchronous I/O operations, and excessive CPU-bound tasks can exhaust the .NET thread pool, preventing new threads from being scheduled for polling.
- To identify the cause of the 100% CPU usage and host thread starvation during the first message execution, review the Application Insights logs. Also, check the application code whether you are creating multiple new threads instead of completing the existing thread to complete the operation this might be one of the causes for high CPU.
- Finally, it is recommended to disable Dynamic Concurrency to avoid the known issue of Azure functions getting stuck running at 100% CPU Azure function gets stuck running to 100% CPU.
Hope this helps, let me know if you have any further questions on this.