Azure / Azure-Functions

1.1k stars 189 forks source link

Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=8.0.0.0' with Microsoft.Azure.WebJobs.Extensions.Storage #2480

Open anime-shed opened 1 month ago

anime-shed commented 1 month ago

New V4 app or existing V3 app migrated to V4: New App in V4

dotnet --version
9.0.100-preview.3.24204.13

Also verified in dotnet 8 sdk

Case

We are creating Azure function v4 with .net core 8.

Error:

image

Packages

image

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
    <ImplicitUsings>enable</ImplicitUsings>
    <SelfContained>false</SelfContained>
    <OutputType>Exe</OutputType>
  </PropertyGroup>
  <ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.22.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.2" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.2.1" />
    <PackageReference Include="DotNetZip" Version="1.16.0" />
    <PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.3.1" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Core" Version="3.0.39" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="5.3.0" />

    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.4" />
      <PackageReference Include="CsvHelper" Version="32.0.2" />
      <PackageReference Include="Polly" Version="8.3.1" />
    <PackageReference Include="Serilog" Version="3.1.1" />
    <PackageReference Include="Telegram.Bot" Version="19.0.0" />
  </ItemGroup>
  <ItemGroup>
    <Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>
bhagyshricompany commented 1 month ago

Thanks for informing will check and confirm the same.

bhagyshricompany commented 1 month ago

I checked it seems fine.can you try again else share your code also.

image image
anime-shed commented 1 month ago

I'm sorry, it's a private project, so I won't be able to share the code. I can provide snippets that may help you debug the cause.

I tried to try again on my project, but for some reason, I am facing:

[2024-05-28T15:16:31.037Z] Found Using for user secrets file configuration.
[2024-05-28T15:16:32.849Z] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
[2024-05-28T15:16:32.899Z] The 'FUNCTIONNAME' function is in error: The binding type(s) 'blobTrigger' are not registered. Please ensure the type is correct and the binding extension is installed.
For detailed output, run func with --verbose flag.
dsgb1987 commented 1 month ago

I am also having the same issue after upgrading from .Net 6 to .Net 8.

Microsoft.Azure.WebJobs.Script: Error building configuration in an external startup class. FileNetWorkFlows.Workflows: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=8.0.0.0

I even attempted adding that package to the project explicitly.

anime-shed commented 1 month ago

@dsgb1987, will it be possible to share your code snippet for @bhagyshricompany since I am facing an error on my end?

bhagyshricompany commented 3 weeks ago
net6.0 v4 Exe enable enable PreserveNewest PreserveNewest Never

sample code using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Azure.Functions.Worker; using Microsoft.Extensions.Logging;

namespace FunctionApp1 { public class Function1 { private readonly ILogger _logger;

    public Function1(ILogger<Function1> logger)
    {
        _logger = logger;
    }

    [Function("Function1")]
    public IActionResult Run([HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequest req)
    {
        _logger.LogInformation("C# HTTP trigger function processed a request.");
        return new OkObjectResult("Welcome to Azure Functions!");
    }
}

}

AbeLouis commented 1 week ago

I'm also having the same issue after upgrading from .net core 6.0 to 8.0 in an azure function. Runs locally but fails in Azure with the above error.

quellatalo commented 1 week ago

it seems this problem happens only when

<Nullable>enable</Nullable>
quellatalo commented 1 week ago

it seems this problem happens only when

<Nullable>enable</Nullable>

It runs fine with the IDEs (Visual Studio or Rider). But on command-line func host start, the problem occurs. I'm using azfunc core tools 4.0.5858.

bhagyshricompany commented 1 week ago

can you upgrade your version.

quellatalo commented 1 week ago

can you upgrade your version.

You mean me? My version is the latest now. (4.0.5858)

I also tried downgrading to your version (4.0.5801) but still the same issue.

bhagyshricompany commented 1 day ago

Try to upgeade your asp.net core versions to latest one from 1.2.0 tolatest.Thanks

quellatalo commented 1 day ago

Thanks. I was using in-progress model. I switched to worker model and the problem is gone.

anime-shed commented 9 hours ago

@quellatalo can you share what you changed?

quellatalo commented 6 hours ago

@anime-shed

@quellatalo can you share what you changed?

Context

I was using InProgress Model (Microsoft.NET.Sdk.Functions) instead of Worker Model. The project was configured with net6.0, and Nullable enabled.

When I changed the target framework to net8.0, I got the same error message about loading Microsoft.Extensions.Configuration.Abstractions, Version=8.0.0.0. NOTE: This problem does not occur when I run the az function using the IDEs (VisualStudio or Rider). It only happens with func core tools func host start.

Solutions

I found 2 ways:

1. Disable Nullable

I tried to investigate by simplify/minimize the project as much as possible. Then when I removed the <Nullable>enable</Nullable> line, the problem was gone.

However, this would break the whole project design. So, I need another approach.

2. Change to Worker Model

There's an article about retiring InProgress Model. So I tried to switch to Worker model to see how it goes... and it just worked, even with Nullable enabled.

Considering your initial implementation is on Worker Model already. I think I can't really help you :(. Maybe checking installed versions might help. (There's a new func core tool 4.0.5907 released.)

Extra info (not sure if it can help)