Azure-functions-durable-extension: DurableClient throws exception using Functions SDK 3.0.4 or later

Created on 3 Mar 2020  路  3Comments  路  Source: Azure/azure-functions-durable-extension

Description

After updating to Functions SDK 3.0.4, an exception was thrown and stopped working.

Microsoft.AspNetCore.Mvc.WebApiCompatShim is no longer supported in ASP.NET Core 3.0.

Expected behavior

Processing is completed without any exception being thrown.

Actual behavior

An exception is thrown.

2020-03-03T05:14:14.862 [Error] Executed 'Function2_HttpStart' (Failed, Id=3eb453bf-3db9-4b3a-a1fe-81b9d797efb1)
Could not load file or assembly 'Microsoft.AspNetCore.Mvc.WebApiCompatShim, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

Relevant source code snippets

public static class Function2
{
    [FunctionName("Function2")]
    public static async Task<List<string>> RunOrchestrator(
        [OrchestrationTrigger] IDurableOrchestrationContext context)
    {
        var outputs = new List<string>();

        // Replace "hello" with the name of your Durable Activity Function.
        outputs.Add(await context.CallActivityAsync<string>("Function2_Hello", "Tokyo"));
        outputs.Add(await context.CallActivityAsync<string>("Function2_Hello", "Seattle"));
        outputs.Add(await context.CallActivityAsync<string>("Function2_Hello", "London"));

        // returns ["Hello Tokyo!", "Hello Seattle!", "Hello London!"]
        return outputs;
    }

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

    [FunctionName("Function2_HttpStart")]
    public static async Task<IActionResult> HttpStart(
        [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequest req,
        [DurableClient] IDurableOrchestrationClient starter,
        ILogger log)
    {
        // Function input comes from the request content.
        string instanceId = await starter.StartNewAsync("Function2", null);

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

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

Known workarounds

Rollback to version 3.0.3

App Details

  • Durable Functions extension version (e.g. v1.8.3): v2.1.1
  • Azure Functions runtime version (1.0 or 2.0): 3.0
  • Programming language used: C#
Needs bug tooling

Most helpful comment

@shibayan,

Great find. We will see if we can get a fix into 2.2.0 for this.

All 3 comments

@ConnorMcMahon
I found the root cause. The cause is a version mismatch of Microsoft.AspNetCore.Mvc.WebApiCompatShim. It works by version down to 2.1.0.

The reason is that the Azure Functions Runtime only includes WebApiCompatShim 2.1.0, and since Function SDK 3.0.4, the behavior has been changed to remove duplicate assemblies.

Building the DurableTask with the version down to WebApiCompatShim 2.1.0 in the development environment worked fine.

@shibayan,

Great find. We will see if we can get a fix into 2.2.0 for this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

val-janeiko picture val-janeiko  路  3Comments

amdeel picture amdeel  路  3Comments

cgillum picture cgillum  路  3Comments

danielearwicker picture danielearwicker  路  3Comments

mpaul31 picture mpaul31  路  3Comments