Function App Crashing Due to System.Net.Http.HttpRequestException

DJ 50 Reputation points
2025-03-09T22:37:50.52+00:00

Hi

I am experiencing recurring crashes on my Azure Function App due to a System.Net.Http.HttpRequestException. The error message indicates an issue with an outgoing HTTP request, and it is causing the function to terminate unexpectedly.

The error message displayed in the Azure portal:
I have never experienced this in the past, but it appears as soon I click on the function app in the portal.


We identified the below thread resulted in a **System.Net.Http.HttpRequestException** for your App aardraapi and application code should be fixed to prevent impact to application availability. ``` System.Net.Http.HttpConnectionPool+<ConnectToTcpHostAsync>d__98.MoveNext System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification System.Threading.Tasks.ValueTask`1[[System.ValueTuple`2[[System.__Canon System.Private.CoreLib][System.__Canon System.Private.CoreLib]] System.Private.CoreLib]].get_Result System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1+ConfiguredValueTaskAwaiter[[System.ValueTuple`2[[System.__Canon System.Private.CoreLib][System.__Canon System.Private.CoreLib]] System.Private.CoreLib]].GetResult System.Net.Http.HttpConnectionPool+<ConnectAsync>d__97.MoveNext System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification System.Threading.Tasks.ValueTask`1[[System.ValueTuple`3[[System.__Canon System.Private.CoreLib][System.__Canon System.Private.CoreLib][System.__Canon System.Private.CoreLib]] System.Private.CoreLib]].get_Result System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1+ConfiguredValueTaskAwaiter[[System.ValueTuple`3[[System.__Canon System.Private.CoreLib][System.__Canon System.Private.CoreLib][System.__Canon System.Private.CoreLib]] System.Private.CoreLib]].GetResult System.Net.Http.HttpConnectionPool+<CreateHttp11ConnectionAsync>d__99.MoveNext System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification System.Threading.Tasks.ValueTask`1[[System.__Canon System.Private.CoreLib]].get_Result System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1+ConfiguredValueTaskAwaiter[[System.__Canon System.Private.CoreLib]].GetResult System.Net.Http.HttpConnectionPool+<AddHttp11ConnectionAsync>d__74.MoveNext System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[[System.__Canon System.Private.CoreLib]].GetResult System.Threading.Tasks.TaskCompletionSourceWithCancellation`1+<WaitWithCancellationAsync>d__1[[System.__Canon System.Private.CoreLib]].MoveNext System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification System.Threading.Tasks.ValueTask`1[[System.__Canon System.Private.CoreLib]].get_Result System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1+ConfiguredValueTaskAwaiter[[System.__Canon System.Private.CoreLib]].GetResult System.Net.Http.HttpConnectionPool+<GetHttp11ConnectionAsync>d__76.MoveNext System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification System.Threading.Tasks.ValueTask`1[[System.__Canon System.Private.CoreLib]].get_Result System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1+ConfiguredValueTaskAwaiter[[System.__Canon System.Private.CoreLib]].GetResult System.Net.Http.HttpConnectionPool+<SendWithVersionDetectionAndRetryAsync>d__84.MoveNext System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[[System.__Canon System.Private.CoreLib]].GetResult System.Net.Http.DiagnosticsHandler+<SendAsyncCore>d__8.MoveNext System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification System.Threading.Tasks.ValueTask`1[[System.__Canon System.Private.CoreLib]].get_Result System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1+ConfiguredValueTaskAwaiter[[System.__Canon System.Private.CoreLib]].GetResult System.Net.Http.RedirectHandler+<SendAsync>d__4.MoveNext System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[[System.__Canon System.Private.CoreLib]].GetResult System.Net.Http.HttpClient+<<SendAsync>g__Core|83_0>d.MoveNext System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification AardraApi.devicecontrol+<Start_check>d__5.MoveNext System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw System.Threading.Tasks.Task+<>c.<ThrowAsync>b__128_1 System.Threading.QueueUserWorkItemCallback+<>c.<.cctor>b__6_0 System.Threading.ExecutionContext.RunForThreadPoolUnsafe[[System.__Canon System.Private.CoreLib]] ``` A crash happens when an exception in your code goes un-handled and terminates the process. When your application crashes, all the in-flight requests (request that are currently being processed by the app) are aborted. An end user may experience an HTTP 502 error for those requests. Azure App Service Platform has a **Proactive Crash Monitoring** feature that attaches a debugger to your process and records the call-stack of the crashing thread whenever your process crashes with an unhandled exception. If the above call stack is not helping in identifying the root cause of the crash, you can enable **Crash Monitoring** feature to collect a memory dump when the process crashes.
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sai Prabhu Naveen Parimi 2,260 Reputation points Microsoft External Staff Moderator
    2025-03-18T09:50:28.3866667+00:00

    @DJ

    No worries about the late reply! Glad to hear that the issue seems to have resolved itself.

    Yes, you can set up Azure Application Insights to send email alerts when such exceptions occur. You can refer to the following documents for step-by-step guidance:

    1. How to Configure Azure Function App Notifications for Errors
    2. Adventures with Azure Functions: Create an Alert from App Insights to Send an Email Notification
    3. Microsoft Docs: Alerts in Azure Monitor

    These should help you set up alerts to monitor and get notified of such exceptions

    Please do not forget to click "Accept the answer” and Yes wherever the information provided helps you, this can be beneficial to other community members.

    If you have any other questions or still running into more issues, let me know in the "comments" and I would be happy to help you.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.