azure-functions-dotnet-worker: Unable to load Function, a function with the id already exists.

I have a queue trigger function that receives events from a queue storage, and the function execution sometimes fails with an error message:

Result: Failure Exception: System.InvalidOperationException: Unable to load Function '[Function name]'. A function with the id '[Function id]' name already exists. at Microsoft.Azure.Functions.Worker.FunctionsApplication.LoadFunction(FunctionDefinition definition) in D:\a\_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 62 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

Basically I have a system topic that is subscribed to “BlobCreated” events in a blob container, which sends the events to the queue storage and those events are then handled by the queue trigger function.

After I upload items to the blob container (100 or less at a time), the function works fine for a while until this error starts occurring. What could possibly cause this error and what does it mean exactly?

I am using these package versions:

<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage.Queues" Version="5.2.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.20.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.16.3" />

host.json:

{
    "version": "2.0",
    "logging": {
        "applicationInsights": {
            "samplingSettings": {
                "isEnabled": true,
                "excludedTypes": "Request"
            }
        }
    },
    "extensions": {
        "queues": {
            "batchSize": 2,
            "newBatchThreshold": 1,
            "maxDequeueCount": 1,
            "messageEncoding": "base64"
        }
    }
}

Program.cs (with business logic removed):

using Microsoft.Extensions.Azure;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

var host = new HostBuilder()
    .ConfigureFunctionsWorkerDefaults()
    .ConfigureServices((services) =>
    {
		... services here
    })
    .Build();

host.Run();

Function looks like this:

[Function("HandleData")]
public async Task Run([QueueTrigger("data-queue")] BlobEvent input)
{
    ...handle data
}

There are no other functions in the Function App

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 34 (5 by maintainers)

Commits related to this issue

Most upvoted comments

we are using .net 8 and seeing below error.

image

Although as workaround we downgrading azure functions worker sdk to 1.15.1 and it resolved the issue.

I believe @kshyju provided the answer to this problem. He says it would be fixed by installing the host version 4.33.0.

I’m using 4.31.1, and I was hoping that by installing the latest Core Tools Version (4.0.5611) I’d get the latest host version (which by the way it is 4.33.2 now: Azure Functions Host Versions)

Unfortunately that’s not the case. Even though I have the latest Core Tools Version, when I launch my .NET 8 Isolated Process, Http Triggered Azure Function, I still see the old 4.31.1 host runtime: image

I believe the problem is that the Azure Functions Core Tools was released a month ago: image Azure-Functions-Core-Tools

And by that time, the host runtime latest version was indeed the one I have (4.31.1): image Azure Functions Host Releases

What can I do to make the Azure Functions Core Tools use the latest host version before its next release?

I tried the following without luck:

PS: By the way, it seems the Core Tools was already updated to the latest version (4.33.2): image azure-functions-core-tools - PR 3646

but the latest release still dates from a month ago: image

@soninaren is actively investigating this. We’ll share more information here once that becomes available.

Seeing this issue again for a .NET 8 isolated function in West Europe

Exception while executing function: Functions.REDACTED Result: Failure
Exception: System.InvalidOperationException: Unable to load Function 'REDACTED'. A function with the id '2444048646' name already exists.
   at Microsoft.Azure.Functions.Worker.FunctionsApplication.LoadFunction(FunctionDefinition definition) in D:\a\_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 62
   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
Stack:    at Microsoft.Azure.Functions.Worker.FunctionsApplication.LoadFunction(FunctionDefinition definition) in D:\a\_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 62
   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 

We are experiencing the same issue. We have just upgraded from .NET 6 (in-process) to .NET 8 (isolated) and we are experiencing the issue of Unable to load Function 'FUNCTION_NAME'. A function with the id '123' name already exists When the function app is restarted it works for a period but then starts to fail with the above message. This is across all of our triggers on all functions on the App:

  • Timer
  • Service Bus
  • HTTP

Adding <FunctionsEnableWorkerIndexing>False</FunctionsEnableWorkerIndexing> does resolve the issue however this seems more like a work around then a fix.

Any update on this @fabiocav ? This is blocking our teams from migrating to the latest SDK version and consuming the performance improvements.

if you have

var host = builder.Build();
await host.RunAsync();

try to change it to

var host = builder.Build();
host.Run();

that oddly worked for me after comparing two different function projects. one that had the issue and one that did not…

My version is “Function Runtime Version: 4.34.1.22669” and I still have the same issue. Functions are on v4 isolated and .net 8.0. Starting from a CLI “func start”.

Core Tools Version: 4.0.5611 Function Runtime Version: 4.31.1.22191

I’m using .NET 8 in the Isolated Model and I can also reproduce it locally with a rather basic setup: I have a single HTTP Triggered Azure Function and when it fails and the exception handling returns a 500, I can no longer call it a 2nd time from PostMan as I see the mentioned error message in the console.

Any news? It’s been almost half a year since this bug was initially reported.

I am running latest Azure Function Core Tools locally 4.0.5611 and I am still seeing this issue.

@preetiduhan / @mtopolski This fix for this issue is available from host version 4.33.0 onwards. What version of core tools/host runtime are you seeing the issue with?

I can repro this on demand injecting a singleton that takes a few seconds to instantiate. Without the expensive DI I don’t see this issue. @preetiduhan I only wish I had seen your comment sooner, this workaround is working for me and I am deeply grateful. Better 3 hours deep into chasing ghosts than never.

Adding <FunctionsEnableWorkerIndexing>False</FunctionsEnableWorkerIndexing> does resolve the issue however this seems more like a work around then a fix.

Second this statement @smackodale. Is there any progress on this item?

@smoothstill Can you share your function app name and region and I can take a closer look at what is going on.

omavoima-meterdata-integrations-staging, North Europe

alarmprocessorbluepillargeneraldev2eastus in East US