Azure Functions: .NET 7 and .NET 8 local debugging bug on Visual Studio Code.

This is a very quick post signaling a bug that makes me spending hours of troubleshooting.

If you’re developing Azure Functions with Visual Studio Code and .NET 7 or .NET 8, when you create a new Azure Function Isolated app project the assembly Microsoft.Azure.Functions.Worker.Sdk version 1.16.x is automatically referenced in your .csproj file:

If you try to debug the Azure Function project locally, you could have the following strange error:

Worker failed to load function: 'HttpTrigger1' with functionId: '3518398034'.
[2023-12-29T14:16:44.171Z] Result: Failure
[2023-12-29T14:16:44.171Z] Exception: System.InvalidOperationException: Unable to load Function 'HttpTrigger1'. A function with the id '3518398034' name already exists.
[2023-12-29T14:16:44.171Z] at Microsoft.Azure.Functions.Worker.FunctionsApplication.LoadFunction(FunctionDefinition definition) in D:\a\_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 62
[2023-12-29T14:16:44.171Z] at Microsoft.Azure.Functions.Worker.GrpcWorker.FunctionLoadRequestHandler(FunctionLoadRequest request, IFunctionsApplication application, IMethodInfoLocator methodInfoLocator) in D:\a\_work\1\s\src\DotNetWorker.Grpc\GrpcWorker.cs:line 269
[2023-12-29T14:16:44.171Z] Stack: at Microsoft.Azure.Functions.Worker.FunctionsApplication.LoadFunction(FunctionDefinition definition) in D:\a\_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 62
[2023-12-29T14:16:44.171Z] at Microsoft.Azure.Functions.Worker.GrpcWorker.FunctionLoadRequestHandler(FunctionLoadRequest request, IFunctionsApplication application, IMethodInfoLocator methodInfoLocator) in D:\a\_work\1\s\src\DotNetWorker.Grpc\GrpcWorker.cs:line 269.

The error is quite tricky…

The workarounds to solve that are:

  • Rolling back Microsoft.Azure.Functions.Worker.Sdk to version 1.15.X
  • Using Microsoft.Azure.Functions.Worker.Sdk 1.16.x by setting in the .csproj file the property <FunctionsEnableWorkerIndexing>False</FunctionsEnableWorkerIndexing> 

Bug is reported to the Azure Functions team, see here.

Hoping that this post helps someone else on avoiding spending hours on troubleshooting.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.