Search code examples
.netazureazure-functionsazure-webjobs

microsoft.extensions.logging.abstractions cannot be found


I upgraded my project to .net 7 and my FunctionApp no longer works. It says that it cannot load the file or assembly Microsoft.extensions.logging.abstractions because the file cannot be found.

Here is my project:

`<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
  </PropertyGroup>
  <ItemGroup>
    <Compile Remove="FunctionInterfaces\**" />
    <Compile Remove="ModuleInterfaces\**" />
    <EmbeddedResource Remove="FunctionInterfaces\**" />
    <EmbeddedResource Remove="ModuleInterfaces\**" />
    <None Remove="FunctionInterfaces\**" />
    <None Remove="ModuleInterfaces\**" />
  </ItemGroup>
  <ItemGroup>
    <None Remove="Modules\MarketModule.cs~RF1b001614.TMP" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="ModuleInterfaces\Base\IModule.cs" />
    <Compile Include="ModuleInterfaces\IExchangeModule.cs" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.33" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="5.0.1" />
    <PackageReference Include="Microsoft.Extensions.Azure" Version="1.6.0" />
    <PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="7.0.0" />
    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.3" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\PMSX.Application\PMSX.Application.csproj" />
    <ProjectReference Include="..\PMSX.Domain\PMSX.Domain.csproj" />
    <ProjectReference Include="..\PMSX.Infrastructure\PMSX.Infrastructure.csproj" />
  </ItemGroup>`

I tried removing microsoft.net.sdk.functions, but that is what specifies that the project is a functionapp. I also tried downgrading webjobs, but that had no effect.


Solution

  • Thanks to @HariKrishna for your suggestion to solve the NuGet Package Microsoft.Extensions.X Upgrade in .NET 6 Azure Functions. It helped for me as well.

    .NET 7 In-process is not yet released yet for Azure Functions V4, and your workarounds shows better solution for using the Microsoft.Extensions.X in compatible versions of Azure Functions.

    But how do I debug my FunctionApp on my Visual Studio?

    You can run the function in debug mode using VS IDE for debugging locally.
    enter image description here

    Change the Release Mode to Debug > Put the breakpoints > Start running the function for debugging locally.

    If the requirement is remote debugging, refer to this MS Doc and SO Thread for more information on configuring the remote debugging on Visual Studio for Azure Functions Project.