azure-functions-dotnet-worker: Azure function startup failure "Could not load file or assembly" after upgrading to latest version
After upgrading the packages:
- Microsoft.Azure.Functions.Worker.Sdk from 1.14.1 to 1.15.1
- Microsoft.Azure.Functions.Worker.Extensions.ServiceBus from 5.13.0 to 5.14.1
My Azure function fails to start up, the error is:
Error configuring services in an external startup class. Could not load file or assembly 'Microsoft.AspNetCore.Routing, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Microsoft.Azure.WebJobs.Script.ExternalStartupException:
System.IO.FileNotFoundException:
at Microsoft.Extensions.DependencyInjection.GrpcServicesExtensions.AddGrpc (Grpc.AspNetCore.Server, Version=2.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad)
at Microsoft.Azure.WebJobs.Extensions.Rpc.WebJobsExtensionBuilderRpcExtensions.AddCoreServices (Microsoft.Azure.WebJobs.Extensions.Rpc, Version=3.0.37.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Extensions.Rpc\WebJobsExtensionBuilderRpcExtensions.cs:39)
at Microsoft.Azure.WebJobs.Extensions.Rpc.WebJobsExtensionBuilderRpcExtensions.MapWorkerGrpcService (Microsoft.Azure.WebJobs.Extensions.Rpc, Version=3.0.37.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Extensions.Rpc\WebJobsExtensionBuilderRpcExtensions.cs:31)
at Microsoft.Extensions.Hosting.ServiceBusHostBuilderExtensions.AddServiceBus (Microsoft.Azure.WebJobs.Extensions.ServiceBus, Version=5.13.3.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)
at Microsoft.Extensions.Hosting.ServiceBusHostBuilderExtensions.AddServiceBus (Microsoft.Azure.WebJobs.Extensions.ServiceBus, Version=5.13.3.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)
at Microsoft.Azure.WebJobs.ServiceBus.ServiceBusWebJobsStartup.Configure (Microsoft.Azure.WebJobs.Extensions.ServiceBus, Version=5.13.3.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)
at Microsoft.Azure.WebJobs.WebJobsBuilderExtensions.ConfigureStartup (Microsoft.Azure.WebJobs.Host, Version=3.0.39.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Hosting\WebJobsBuilderExtensions.cs:166)
at Microsoft.Azure.WebJobs.WebJobsBuilderExtensions.ConfigureAndLogUserConfiguredServices (Microsoft.Azure.WebJobs.Host, Version=3.0.39.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Hosting\WebJobsBuilderExtensions.cs:130)
at Microsoft.Azure.WebJobs.WebJobsBuilderExtensions.UseWebJobsStartup (Microsoft.Azure.WebJobs.Host, Version=3.0.39.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Hosting\WebJobsBuilderExtensions.cs:115)
at Microsoft.Azure.WebJobs.WebJobsBuilderExtensions.UseExternalStartup (Microsoft.Azure.WebJobs.Host, Version=3.0.39.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Hosting\WebJobsBuilderExtensions.cs:213)
at Microsoft.Azure.WebJobs.Script.ScriptHostBuilderExtensions+<>c__DisplayClass7_0.<AddScriptHostCore>b__1 (Microsoft.Azure.WebJobs.Script, Version=4.27.0.0, Culture=neutral, PublicKeyToken=null: /src/azure-functions-host/src/WebJobs.Script/ScriptHostBuilderExtensions.cs:226)
Downgrading Worker.Sdk back to 1.14.1 and Worker.Extensions.ServiceBus back to 5.13.0 fixed the issue. This is a similar experience to what was reported in #1950, but different packages.
The complete list of packages used in my project is:
<PackageReference Include="Azure.Identity" Version="1.10.3" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.18.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.19.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.15.1" OutputItemType="Analyzer" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.2.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage" Version="6.2.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.14.1" />
<PackageReference Include="CommandQuery.DependencyInjection" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="7.0.13" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="6.1.1" />
Let me know if you need more information.
About this issue
- Original URL
- State: open
- Created 8 months ago
- Reactions: 6
- Comments: 45 (14 by maintainers)
Commits related to this issue
- Fix Azure function dependency issue (https://github.com/Azure/azure-functions-dotnet-worker/issues/1995) Refactor project structure and to remove unnecessary dependencies Update NuGet packages to lat... — committed to Steam-Community-Market-Manager/SCMM by rhyskoedijk 8 months ago
- Improve reliability of market price data jobs (#44) * Fix Azure function dependency issue (https://github.com/Azure/azure-functions-dotnet-worker/issues/1995) Refactor project structure and to rem... — committed to Steam-Community-Market-Manager/SCMM by rhyskoedijk 8 months ago
I believe I have gotten to the root of this issue thanks to help from @Krumelur . The issue is VS publish, it is passing an explicit
TargetFramework=net8.0
argument to the publish, which overrides the inner project TFM ofnet6.0
, which causes the net7.0 copy ofGrpc.AspNetCore.Server
to be included and thus the load issues.Mitigation: In Visual Studio solution explorer, open your publish profile (ie:
Properties/PublishProfiles/{appName} - Zip Deploy.pubxml
). Delete the line that contains<TargetFramework>net8.0</TargetFramework>
then publish. NOTE: Visual Studio will re-add this property next time you edit and save publish settings (below). IfTarget Framework
is listed in the below area, then you will need to perform the delete again.Fix: I will fix this properly in our SDK, we need expand on the set of global properties to ignore when invoking the inner build. TFM is one of them.
I think I figured this out. @rhyskoedijk can you try with the latest SDK
1.16.3
and latest ServiceBus extension?What I think is happening is for a bit we had a version of the SDK which would set the inner-build csproj’s TFM to be
net7.0
if your project wasnet7.0
. This causes a bug where now multi-targeted packages that had a net7.0 TFM would be brought in, and could end up depending on AspNetCore 7.0. This is what I see happening with your project. The generatedWorkerExtension.csproj
targetsnet7.0
andGrpc.AspNetCore.Server
ends up depending onMicrosoft.AspNetCore.Routing/7.0.0
, which is not found when deployed since we only have the net6.0 of AspNetCore on the machine.After updating the Worker SDK to latest on your project I saw
Grpc.AspNetCore.Server
now referenceMicrosoft.AspNetCore.Routing/6.0.0
, which makes me believe it should work when deployed.@jviau That worked! I removed -f net8.0 from my Github Action and now the function app runs fine. Thank you for your help!
@KelvisGama the diagnostic source issue is different. That would be an explicit reference to that package by you or an extension.
7.0.0
of that package also is not supported on the host side (its fine to use for your worker in dotnet isolated, but WebJobs extensions cannot use it).We have the same issue after updating Microsoft.Azure.Functions.Worker.Extensions.ServiceBus to the latest version. It doesn’t work with 5.14.0 as well.
@dush88c The project file you shared above does not look like the one for a dotnet isolated project. For dotnet in-proc apps, please open an issue in the host repo (https://github.com/Azure/azure-functions-host)