How to fix Microsoft.Azure.WebJobs.Host.FunctionInvocationException on a windows function app?

Jonathan Stefani 0 Reputation points
2024-04-25T21:34:21.59+00:00

I have a durable function app running in Azure that works on Linux but throws an exception when ran on Windows. The exception is a Microsoft.Azure.WebJobs.Host.FunctionInvocationException with this error:

System.InvalidCastException: Unable to cast object of type 'System.String' to type 'Microsoft.Azure.WebJobs.Extensions.DurableTask.IDurableOrchestrationContext'.
   at lambda_method463(Closure , ProcessSave , Object[] )
   at Microsoft.Azure.WebJobs.Host.Executors.TaskMethodInvoker`2.InvokeAsync(TReflected instance, Object[] arguments) in D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Executors\TaskMethodInvoker.cs:line 21

The odd thing is that the durable function runs with no errors on a Linux instance. I already tried updating all my dependencies as I have seen mentioned in other places.

Any ideas on how to fix this?

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

1 answer

Sort by: Most helpful
  1. Claus Jakobsen 5 Reputation points
    2024-05-03T13:27:02.6333333+00:00

    I had the same problem and found that is was caused by the Azure Function being set to isolated mode. Removing that fixed the problem.

    1 person found this answer helpful.

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.