Azure function fails with FunctionInvocationException, Actually I have Update .net 6 to .net 8 and updated all packages

Balasubrahmanyam Tekimudi 35 Reputation points
2024-03-06T14:05:38.91+00:00

For detailed output, run func with --verbose flag.

[2024-03-06T13:54:39.549Z] Host lock lease acquired by instance ID '0000000000000000000000006F297016'.

[2024-03-06T13:55:16.662Z] Function 'HealthCheck', Invocation id 'a6026686-5dd8-4fbe-8049-c15d6f4f201f': An exception was thrown by the invocation.

[2024-03-06T13:55:16.663Z] Result: Function 'HealthCheck', Invocation id 'a6026686-5dd8-4fbe-8049-c15d6f4f201f': An exception was thrown by the invocation.

Exception: System.Threading.Tasks.TaskCanceledException: A task was canceled.

[2024-03-06T13:55:16.664Z] at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.DefaultHttpCoordinator.SetFunctionContextAsync(String invocationId, FunctionContext context) in D:\a_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\Coordinator\DefaultHttpCoordinator.cs:line 35

[2024-03-06T13:55:16.664Z] at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.FunctionsHttpProxyingMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\FunctionsMiddleware\FunctionsHttpProxyingMiddleware.cs:line 41

[2024-03-06T13:55:16.665Z] at Microsoft.Azure.Functions.Worker.FunctionsApplication.InvokeFunctionAsync(FunctionContext context) in D:\a_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 77

Stack: at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.DefaultHttpCoordinator.SetFunctionContextAsync(String invocationId, FunctionContext context) in D:\a_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\Coordinator\DefaultHttpCoordinator.cs:line 35

[2024-03-06T13:55:16.666Z] at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.FunctionsHttpProxyingMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\FunctionsMiddleware\FunctionsHttpProxyingMiddleware.cs:line 41

[2024-03-06T13:55:16.667Z] at Microsoft.Azure.Functions.Worker.FunctionsApplication.InvokeFunctionAsync(FunctionContext context) in D:\a_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 77.

[2024-03-06T13:55:16.694Z] Executed 'Functions.HealthCheck' (Failed, Id=a6026686-5dd8-4fbe-8049-c15d6f4f201f, Duration=38392ms)

[2024-03-06T13:55:16.696Z] System.Private.CoreLib: Exception while executing function: Functions.HealthCheck. System.Private.CoreLib: Result: Failure

Exception: System.Threading.Tasks.TaskCanceledException: A task was canceled.

[2024-03-06T13:55:16.697Z] at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.DefaultHttpCoordinator.SetFunctionContextAsync(String invocationId, FunctionContext context) in D:\a_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\Coordinator\DefaultHttpCoordinator.cs:line 35

[2024-03-06T13:55:16.698Z] at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.FunctionsHttpProxyingMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\FunctionsMiddleware\FunctionsHttpProxyingMiddleware.cs:line 41

[2024-03-06T13:55:16.699Z] at Microsoft.Azure.Functions.Worker.FunctionsApplication.InvokeFunctionAsync(FunctionContext context) in D:\a_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 77

[2024-03-06T13:55:16.700Z] at Microsoft.Azure.Functions.Worker.Handlers.InvocationHandler.InvokeAsync(InvocationRequest request) in D:\a_work\1\s\src\DotNetWorker.Grpc\Handlers\InvocationHandler.cs:line 88

Stack: at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.DefaultHttpCoordinator.SetFunctionContextAsync(String invocationId, FunctionContext context) in D:\a_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\Coordinator\DefaultHttpCoordinator.cs:line 35

[2024-03-06T13:55:16.701Z] at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.FunctionsHttpProxyingMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\FunctionsMiddleware\FunctionsHttpProxyingMiddleware.cs:line 41

[2024-03-06T13:55:16.702Z] at Microsoft.Azure.Functions.Worker.FunctionsApplication.InvokeFunctionAsync(FunctionContext context) in D:\a_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 77

[2024-03-06T13:55:16.704Z] at Microsoft.Azure.Functions.Worker.Handlers.InvocationHandler.InvokeAsync(InvocationRequest request) in D:\a_work\1\s\src\DotNetWorker.Grpc\Handlers\InvocationHandler.cs:line 88.

[2024-03-06T13:55:54.878Z] Function 'ReadCache', Invocation id 'fa6afe3a-b39d-440e-a81a-fa2ac5ed13f8': An exception was thrown by the invocation.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,085 questions
0 comments No comments
{count} votes

7 answers

Sort by: Most helpful
  1. Thomas Ardal 20 Reputation points
    2024-06-04T08:25:39.1033333+00:00

    I have the same problem. An isolated function app running on .NET 6 worked fine. After upgrading to .NET 8, I started seeing a lot of these errors in the log:

    Function '{functionName}', Invocation id '{invocationId}': An exception was thrown by the invocation.
    

    This seems to be logged before even reaching my code. Here's the stack trace:

    System.Threading.Tasks.TaskCanceledException: A task was canceled.
       at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.DefaultHttpCoordinator.SetFunctionContextAsync(String invocationId, FunctionContext context) in D:\a\_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\Coordinator\DefaultHttpCoordinator.cs:line 35
       at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.FunctionsHttpProxyingMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a\_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\FunctionsMiddleware\FunctionsHttpProxyingMiddleware.cs:line 41
       at Microsoft.Azure.Functions.Worker.FunctionsApplication.InvokeFunctionAsync(FunctionContext context) in D:\a\_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 89
    

  2. Benali Nabil 0 Reputation points
    2024-10-17T06:18:10.06+00:00

    I have exactly the same issue any solution for this yet !?

    0 comments No comments

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.