Upgrading Dotnet-Isolated Azure Function from .NET 6.0 to .NET 8.0, WorkerExtensions Causing Problems

Shane Rowley (Data Sagacity) 0 Reputation points
2025-02-26T06:24:12.6866667+00:00

I've been trying to update my .NET Isolated Azure Function from .NET 6.0 to .NET 8.0.

My project is using the following packages

<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="2.0.0" />

<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.2.0" />

<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.0.0" />

These packages are used by the function declaration(s):

[Function("MyFunction")]
public async Task<HttpResponseData> Run([HttpTrigger(AuthorizationLevel.Function, "post", Route = "MyFunction")] HttpRequestData request)

For unreasons, when I attempt to publish, the publish fails due to two 'csproj' files in the built code. An additional rogue csproj gets created for unknown reasons. The offender is ".\obj\Release\net8.0\WorkerExtensions\WorkerExtensions.csproj". Plus it's in "obj" and still causes problems.

There are also a bunch of '.net6.0' files located here even though I full upgraded everything to .net8.0.

".\obj\Release\net8.0\WorkerExtensions\obj\Release\net6.0"

I don't have any explicit reference to this 'WorkerExtensions'. I don't know why it exists. I did try removing those 'Functions.Worker' packages and build my functions using WebJobs. It compiled and able to be published. But no Http Triggers were visible on my Azure Function, assumingly because using a Dotnet isolated function.

If it helps, the published code contains these mysterious references to "Microsoft.Azure.Functions.Worker.Extensions/1.0.0" in "\bin\Release\net8.0.azurefunctions\function.deps.json"

As a hack, I am able to publish my function only via script that (1) builds the function, (2) explicitly deletes the offender 'csproj' file out of the 'obj' in the built files and then (3) publish it. The Azure function then runs, without issue and none the wiser.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RithwikBojja 3,055 Reputation points Microsoft External Staff Moderator
    2025-02-27T04:11:40.6333333+00:00

    Hi @ Shane Rowley (Data Sagacity),

    Your issue clearly states that there are multiple references to .net6, even after upgrading it to .net8. I would suggest you to clean the project at once and rebuild it , so that only new packages in the project's csproj will be published.

    First remove all the unwanted files and double files and then clean and rebuild the project:

    enter image description here

    And also this HttpResponseData is in lower version of .net and not in .net 8. So try to update your code as below:

    
        using System;
    
        using System.IO;
    
        using System.Threading.Tasks;
    
        using Microsoft.AspNetCore.Mvc;
    
        using Microsoft.Azure.WebJobs;
    
        using Microsoft.Azure.WebJobs.Extensions.Http;
    
        using Microsoft.AspNetCore.Http;
    
        using Microsoft.Extensions.Logging;
    
        using Newtonsoft.Json;
    
        
    
        namespace FunctionApp3
    
        {
    
            public static class Function1
    
            {
    
                [FunctionName("Function1")]
    
                public static async Task<IActionResult> Run(
    
                    [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
    
                    ILogger rilg)
    
                {
    
                    rilg.LogInformation("C# HTTP trigger function processed a request.");
    
                    string responseMessage = "Hello Rithwik";
    
                    return new OkObjectResult(responseMessage);
    
                }
    
            }
    
        }
    
    

    Try below commands:

    
        dotnet clean
    
        rd /s /q bin
    
        rd /s /q obj
    
        dotnet restore
    
        dotnet build
    
    

    Also update all the nuget packages as below:

    enter image description here

    As the issue is in local environment, I would suggest you to trouble shoot all the possible ways and last resort would be creating a new .net8 project and adding your functions over there.

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.


Your answer

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