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.
Processing is completed without any exception being thrown.
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.
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);
}
}
Rollback to version 3.0.3
@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.
Most helpful comment
@shibayan,
Great find. We will see if we can get a fix into 2.2.0 for this.