Search code examples
azure-functions.net-6.0azure-durable-functionsazure-webjobssdk

Compilation Error: 'IDurableOrchestrationClient' Not Found After Upgrading to .NET 6.0 with Azure Functions


I recently upgraded an Azure Functions project from .NET Core 3.1 to .NET 6.0 using the .NET Upgrade Assistant. After resolving a few issues, I am now stuck on a compilation error that I cannot seem to resolve. The error message is as follows:

The type or namespace name 'IDurableOrchestrationClient' could not be found (are you missing a using directive or an assembly reference?)

Here is the relevant code snippet where the error occurs:

[FunctionName("FunctionName")]
public async Task Run(
    [OrchestrationTrigger] IDurableOrchestrationContext context,
    [DurableClient] IDurableOrchestrationClient client)
{
    // Function code
}

Any guidance on how to resolve this error and successfully upgrade my Azure Functions project to .NET 6.0 would be greatly appreciated!

I have already tried adding the using Microsoft.Azure.WebJobs.Extensions.DurableTask; directive at the top of my file and ensured that the Microsoft.Azure.WebJobs.Extensions.DurableTask NuGet package is installed and updated to the latest version (2.12.0) which supports .NET Core 3.1. However, this package doesn't support .NET 6.0.

I also came across the Microsoft.Azure.Functions.Worker.Extensions.DurableTask package which seems to be for .NET 5.0, but I am unsure if this is the correct package to use or how to use it to resolve the error.


Solution

  • Upgrade your Azure Functions project to .NET 6.0 with Durable Functions, and Install the Microsoft.Azure.Functions.Worker.Extensions.DurableTask package

    enter image description here

    • Update the function signature to use the DurableOrchestrationContext and DurableOrchestrationClient from the new package.
    using Microsoft.Azure.WebJobs.Extensions.DurableTask;
    using Microsoft.Azure.WebJobs.Extensions.Http;
    
    namespace FunctionApp21
    {
        public static class Function1
        {
            [FunctionName("Function1")]
            public static async Task<List<string>> RunOrchestrator(
                [OrchestrationTrigger] IDurableOrchestrationContext context,
                [DurableClient] IDurableOrchestrationClient client)
            {
                var outputs = new List<string>();
    
    // write your function app code.
    

    Give your storage account conn_string.

    enter image description here

    Result: enter image description here