最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

dynamics crm - While working on durable function in azure apps i got this error while it published to online it is perfectly wor

programmeradmin3浏览0评论

"message": "Function 'UpdateCustomerDetails_Orchestrator' failed with an unhandled exception.",
"details": "Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: UpdateCustomerDetails_Orchestrator

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

at lambda_method172(Closure, HttpTriggerFunction, Object[])
at Microsoft.Azure.WebJobs.Host.Executors.TaskMethodInvoker2.InvokeAsync(TReflected instance, Object[] arguments) in D:\\a\\_work\\1\\s\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\TaskMethodInvoker.cs:line 21 at Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker2.InvokeAsync(Object instance, Object[] arguments) in D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionInvoker.cs:line 53
at Microsoft.Azure.WebJobs.Extensions.DurableTask.OutOfProcMiddleware.<>c__DisplayClass10_0.<

this error is encountered after publishing the app it says the orchestrator is failed

"message": "Function 'UpdateCustomerDetails_Orchestrator' failed with an unhandled exception.",
"details": "Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: UpdateCustomerDetails_Orchestrator

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

at lambda_method172(Closure, HttpTriggerFunction, Object[])
at Microsoft.Azure.WebJobs.Host.Executors.TaskMethodInvoker2.InvokeAsync(TReflected instance, Object[] arguments) in D:\\a\\_work\\1\\s\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\TaskMethodInvoker.cs:line 21 at Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker2.InvokeAsync(Object instance, Object[] arguments) in D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionInvoker.cs:line 53
at Microsoft.Azure.WebJobs.Extensions.DurableTask.OutOfProcMiddleware.<>c__DisplayClass10_0.<

this error is encountered after publishing the app it says the orchestrator is failed

Share Improve this question edited Mar 20 at 4:38 Arun Cs asked Mar 19 at 11:50 Arun CsArun Cs 11 bronze badge 2
  • Provide your function code and more details about the error. – Pravallika KV Commented Mar 19 at 12:00
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Bot Commented Mar 19 at 14:38
Add a comment  | 

1 Answer 1

Reset to default 0

Looks like the error is due to how the orchestrator function is being invoked, particularly with the data being passed to it. For example, a string is being passed when an IDurableOrchestrationContext is expected.

  • This could also be due to the Durable Functions misconfiguration in portal. Verify the runtime stack in the function app.

  • Looks like your function is In-Process. Check if you have selected DOTNET-ISOLATED|version(8.0/9.0) as runtime stack. Change the runtime stack to DOTNET|8.0.

The function runtime may be misidentifying it due to various reasons as below:

  • Invalid trigger attribute
  • Deployment mismatch
  • Function runtime version conflict
  • Incorrect function.json generation
  1. Double-check your function attributes: Make sure the function is properly decorated with [FunctionName("UpdateCustomerDetails_Orchestrator")] and uses [OrchestrationTrigger].
  2. Delete bin/obj folders of your project, to ensure a clean publish.
  3. Clean and rebuild your project before publishing to ensure no all DLLs get deployed properly.
  4. Ensure you're using the correct extension bundles and versions in host.json and local.settings.json.

Compare your code structure with the below sample code:

public static class Function1
{
    [FunctionName("Function1")]
    public static async Task<List<string>> RunOrchestrator(
        [OrchestrationTrigger] IDurableOrchestrationContext context)
    {
        var outputs = new List<string>();
        outputs.Add(await context.CallActivityAsync<string>(nameof(SayHello), "Tokyo"));
        outputs.Add(await context.CallActivityAsync<string>(nameof(SayHello), "Seattle"));
        outputs.Add(await context.CallActivityAsync<string>(nameof(SayHello), "London"));
        
        return outputs;
    }

    [FunctionName(nameof(SayHello))]
    public static string SayHello([ActivityTrigger] string name, ILogger log)
    {
        log.LogInformation("Saying hello to {name}.", name);
        return $"Hello {name}!";
    }

    [FunctionName("Function1_HttpStart")]
    public static async Task<HttpResponseMessage> HttpStart(
        [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestMessage req,
        [DurableClient] IDurableOrchestrationClient starter,
        ILogger log)
    {
        string instanceId = await starter.StartNewAsync("Function1", null);

        log.LogInformation("Started orchestration with ID = '{instanceId}'.", instanceId);

        return starter.CreateCheckStatusResponse(req, instanceId);
    }
}

local.settings.json:

{
    "IsEncrypted": false,
    "Values": {
        "AzureWebJobsStorage": "UseDevelopmentStorage=true",
        "FUNCTIONS_INPROC_NET8_ENABLED": "1",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet"
    }
}

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论