Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
anime-shed opened this issue May 9, 2024 · 18 comments

Comments

@anime-shed
Copy link

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 bhagyshricompany self-assigned this May 20, 2024
@bhagyshricompany
Copy link

Thanks for informing will check and confirm the same.

@bhagyshricompany
Copy link

bhagyshricompany commented May 24, 2024

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

@anime-shed
Copy link
Author

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
Copy link

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
Copy link
Author

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

@bhagyshricompany
Copy link

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
Copy link

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
Copy link

it seems this problem happens only when

<Nullable>enable</Nullable>

@quellatalo
Copy link

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
Copy link

can you upgrade your version.

@quellatalo
Copy link

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
Copy link

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

@quellatalo
Copy link

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

@anime-shed
Copy link
Author

@quellatalo can you share what you changed?

@quellatalo
Copy link

quellatalo commented Jul 3, 2024

@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)

  • the updated function csproj
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <IsPackable>true</IsPackable>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
    <OutputType>Exe</OutputType>
  </PropertyGroup>
  <ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.22.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.2.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.3.2" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.2" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.6" />
    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
    <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
    <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>
  • func --version: 4.0.5907
  • dotnet --version: 8.0.302

@anime-shed
Copy link
Author

anime-shed commented Jul 4, 2024

In my case, I also switched to the worker model after reading the documentation shared, but for me, the error occurred while debugging with Visual Studio. I will close this for now since I no longer have the original implementation that had the issue.

@Wind010
Copy link

Wind010 commented Sep 9, 2024

In my case, I also switched to the worker model after reading the documentation shared, but for me, the error occurred while debugging with Visual Studio. I will close this for now since I no longer have the original implementation that had the issue.

Same here for Durable Functions.

@jacekbajerh-f
Copy link

@Wind010 We had the same issue with durable functions. The solution is to remove bin anb obj folders, rebuild and this error will despair. All orchestrators attributes and reference classes should be changed to those from Microsoft.Azure.Functions.Worker.Extensions.DurableTask. Here are our packages:
image
Keep in mind that not all functions from Microsoft.Azure.WebJobs.Extensions.DurableTask where mover already. Here an example: Azure/azure-functions-durable-extension#2810

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants