After upgrade to inprocess to isoalted getting error in Mian Orch function

Jinugu, Manasa 0 Reputation points
2025-11-30T06:49:31.2833333+00:00

After upgrade to isolated getting below error.

Executed 'MainOrch' (Failed, Id=877cad73-d4ac-40aa-bf72-f62f08052dd2, Duration=8ms)

2025-11-30T06:03:38Z [Error] d4db78bad0ae4468972ac1823a72134d: Function 'MainOrch (Orchestrator)' failed with an error. Reason: Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: MainOrch

---> System.InvalidCastException: Unable to cast object of type 'System.String' to type 'Microsoft.Azure.WebJobs.Extensions.DurableTask.IDurableOrchestrationContext'.

at lambda_method153(Closure, PbarFileProcessor, Object[])

I have AzureWebjobsDashboard setting in my AppSettings, should i remove that setting?

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

1 answer

Sort by: Most helpful
  1. Siddhesh Desai 655 Reputation points Microsoft External Staff Moderator
    2025-12-03T06:27:26.8233333+00:00

    Hi @Jinugu, Manasa,

    Thank you for reaching out to Microsoft Q&A

    One difference between Isolated and InProcess Function is Isolated Function requires Program.cs which is missing in InProcess Function trigger.

    I tried migrating my InProcess code to Isolated and here are my migrated code files:

    My folder structure:

    User's image

    My Function1.cs:

    using Microsoft.AspNetCore.Http;
    using Microsoft.AspNetCore.Mvc;
    using Microsoft.Azure.Functions.Worker;
    using Microsoft.Extensions.Logging;
    namespace FunctionAppIsolated;
    public class Function1
    {
        private readonly ILogger<Function1> _logger;
        public Function1(ILogger<Function1> logger)
        {
            _logger = logger;
        }
        [Function("Function1")]
        public IActionResult Run([HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequest req)
        {
            _logger.LogInformation("C# HTTP trigger function processed a request.");
            return new OkObjectResult("Welcome to Azure Functions!");
        }
    }
    
    
    

    My Program.cs: If Program.cs file does not exist, Create one at Function folder root

    using Microsoft.Azure.Functions.Worker;
    using Microsoft.Azure.Functions.Worker.Builder;
    using Microsoft.Extensions.DependencyInjection;
    using Microsoft.Extensions.Hosting;
    var builder = FunctionsApplication.CreateBuilder(args);
    builder.ConfigureFunctionsWebApplication();
    builder.Services
        .AddApplicationInsightsTelemetryWorkerService()
        .ConfigureFunctionsApplicationInsights();
    builder.Build().Run();
    

    My host.json:

    {
      "version": "2.0",
      "logging": {
        "applicationInsights": {
          "samplingSettings": {
            "isEnabled": true,
            "excludedTypes": "Request"
          },
          "enableLiveMetricsFilters": true
        }
      }
    }
    

    My local.settings.json:

    {
      "IsEncrypted": false,
      "Values": {
        "AzureWebJobsStorage": "UseDevelopmentStorage=true",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
      }
    }
    
    
    

    My csproj file:

    Project Sdk="Microsoft.NET.Sdk">
    	<PropertyGroup>
    		<TargetFramework>net8.0</TargetFramework>
    		<AzureFunctionsVersion>v4</AzureFunctionsVersion>
    		<OutputType>Exe</OutputType>
    		<ImplicitUsings>enable</ImplicitUsings>
    		<Nullable>enable</Nullable>
    	</PropertyGroup>
    	<ItemGroup>
    		<FrameworkReference Include="Microsoft.AspNetCore.App" />
    		<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.23.0" />
    		<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="2.50.0" />
    		<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="2.50.0" />
    		<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="2.1.0" />
    		<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.0.6" />
    	</ItemGroup>
    </Project>
    
    
    

    This Function runs successfully locallyUser's image I deployed this Function in Function app, and it got deployed and ran successfully:User's image

    My Function app run stack is: Dotnet-isolated - 8.0

    In case the Function still fails, Set the WEBSITE_RUN_FROM_PACKAGE = 0 to setting, once its set to 0 delete all the DLLS from your Function app Kudu console, once all DLL's and files are deleted from your function app re-deploy the Function trigger and see if it works.

    0 comments No comments

Your answer

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