Azure-Functions icon indicating copy to clipboard operation
Azure-Functions copied to clipboard

When EF7 RC is referenced from a Function App, the app throws a runtime error on startup

Open ajcvickers opened this issue 3 years ago • 3 comments

Moved from https://github.com/dotnet/efcore/issues/29123 since we failed to get any input there.


A minimal reproduceable repo is here: https://github.com/elninoisback/ef7rc-fnapp-issue

The following error is thrown in the console when the function app startsup. It goes away when you remove the ef core dependancy,

The 'Function1' function is in error: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

The following is my .csproj file of the function app.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
    <RootNamespace>ef7rc_fnapp_issue</RootNamespace>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.0-rc.1.22426.7" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.1" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>

EF Core version: 7.0.0-rc.1.22426.7 Database provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer) Target framework: (e.g. .NET 6.0) Operating system: Windows 10 Pro IDE: Visual Studio Enterprise 2022

ajcvickers avatar Oct 06 '22 12:10 ajcvickers

/cc @elninoisback

ajcvickers avatar Oct 06 '22 12:10 ajcvickers

@ajcvickers Please use the below SO for the solution guide, https://stackoverflow.com/questions/58510301/could-not-load-file-or-assembly-microsoft-extensions-logging-abstractions If you still need help please provide us the function app name, timestamp and invocation id details so that we can check for the system logs and update you.

ramya894 avatar Oct 17 '22 13:10 ramya894

@ramya894 Note that I transferred this issue on behalf of a customer.

@elninoisback Please see the response from @ramya894 above.

ajcvickers avatar Oct 17 '22 13:10 ajcvickers

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

ghost avatar Oct 22 '22 15:10 ghost

@ajcvickers Please use the below SO for the solution guide, https://stackoverflow.com/questions/58510301/could-not-load-file-or-assembly-microsoft-extensions-logging-abstractions If you still need help please provide us the function app name, timestamp and invocation id details so that we can check for the system logs and update you.

I don't think the mentioned SO addresses my issue. Infact, my issue is pretty basic, you create a new fnapp, refer the new ef core and it doesn't run (locally). I don't have any hosted ones to let you check the logs, this all happens locally.

elninoisback avatar Oct 22 '22 15:10 elninoisback

For me it worked by switching to dotnet-isolated (https://github.com/Azure/azure-functions-dotnet-worker/tree/main/samples/FunctionApp) fair amount of work but likely needed until functions upgrades some of its core dependencies

bzbetty avatar Oct 22 '22 18:10 bzbetty

For me it worked by switching to dotnet-isolated (https://github.com/Azure/azure-functions-dotnet-worker/tree/main/samples/FunctionApp) fair amount of work but likely needed until functions upgrades some of its core dependencies

Yeah, that's exactly what I've been doing till this point. It's too much work though. (I mentioned it here: https://github.com/dotnet/efcore/issues/29123#issuecomment-1250317693)

elninoisback avatar Oct 24 '22 03:10 elninoisback

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

ghost avatar Oct 28 '22 06:10 ghost

Having the same problem with trying to upgrade an existing .NET6 Functions V4 app also in process hosted and updated the EF Core packages to V7 today and cant even start them anymore in debugger.

Gevil avatar Nov 10 '22 17:11 Gevil

opened an issue here as well as it might be related to that extension package not being maintained properly for Functions DI https://github.com/Azure/azure-functions-dotnet-extensions/issues/72

Gevil avatar Nov 10 '22 17:11 Gevil

Is there any workaround for this apart from switching to isolated functions? Will this be going to be fixed in future versions of azure functions?

hasnuzama avatar May 09 '23 09:05 hasnuzama

Not sure why they are not thinking about backwards compatibility on such level. We had to go back to using in process functions due to this.

I understand that the function teams want to us to go forward using isolated functions, but lots of things are still broken there and we cant just jump on there without certain thing being supported first...

One example being binding to actual Service Bus Message types.

Gevil avatar May 09 '23 12:05 Gevil

is there any workaround for this other switching to isolated function?

SrinivasPam avatar Feb 21 '24 16:02 SrinivasPam