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

Jonathan Stefani 0 Reputation points

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.
4,357 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Claus Jakobsen 0 Reputation points

    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.