Azure / azure-functions-core-tools

Command line tools for Azure Functions
MIT License
1.3k stars 430 forks source link

Intermittent Error when starting functions app #3455

Open kylekirkby opened 1 year ago

kylekirkby commented 1 year ago

Hi all,

We've been getting an intermittent error that prevents us from moving forward at all.

Starting the listener for prefix='', monitoredContainer='CONTAINER_NAME', monitoredDatabase='DB_NAME', leaseContainer='leases', leaseDatabase='DB_NAME', functionId='Host.Functions.FUNCTION_NAME' failed. Exception: System.InvalidOperationException: This builder instance has already been used to build a processor. Create a new instance to build another.
[2023-09-14T12:05:56.295Z]    at Microsoft.Azure.Cosmos.ChangeFeedProcessorBuilder.Build()
[2023-09-14T12:05:56.296Z]    at Microsoft.Azure.WebJobs.Extensions.CosmosDB.CosmosDBTriggerListener`1.StartProcessorAsync() in D:\a\_work\1\s\src\WebJobs.Extensions.CosmosDB\Trigger\CosmosDBTriggerListener.cs:line 140
[2023-09-14T12:05:56.296Z]    at Microsoft.Azure.WebJobs.Extensions.CosmosDB.CosmosDBTriggerListener`1.StartAsync(CancellationToken cancellationToken) in D:\a\_work\1\s\src\WebJobs.Extensions.CosmosDB\Trigger\CosmosDBTriggerListener.cs:line 96.
[2023-09-14T12:05:56.297Z] The listener for function 'Functions.FUNCTION_NAME' was unable to start.
[2023-09-14T12:05:56.297Z] The listener for function 'Functions.FUNCTION_NAME' was unable to start. Microsoft.Azure.Cosmos.Client: This builder instance has already been used to build a processor. Create a new instance to build another.

We've tried countless things to attempt to fix this but it seems the only way we can get around this at the moment is to uninstall the Azure Cosmos DB emulator / remove CosmosDBEmulator folder from %localappdata% and reinstall everything... Even that sometimes does not work. There must be something simple we're missing here. Any pointers as to how we can fix this would be greatly appreciated.

Cheers,

Kyle

tnsholding commented 11 months ago

Seeing the same issue - any updates on this?

kylekirkby commented 11 months ago

@tnsholding @ejizba @soninaren @Francisco-Gamino

Looks like the Microsoft Azure team have abandoned this project..?

The support over on the AWS equivalent (AWS Amplify) is so much better.

3 weeks and no reply from a maintainer?

I'm up for submitting a PR.... just some guidance or any response would be good 👍🏼

dharmitvyas commented 10 months ago

@kylekirkby

I was also getting the same issue. In my case, I missed configuring below two properties in CosmosDBTrigger attribute. LeaseContainerName = "leases", CreateLeaseContainerIfNotExists = true

do you have these properties configured in your CosmosDBTrigger?

drorata commented 7 months ago

@dharmitvyas

Thanks for this hint!! I added these two attributes to the signature of my @app.cosmos_db_trigger and got rid of the error Starting the listener for prefix='', monitoredContainer....

Now, instead, I have the error:

Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.parse_email'. Microsoft.Azure.WebJobs.Extensions.CosmosDB: Cannot create container information for CONTAINERNAME in database DATABASENAME with lease LEASES in database DATABASENAME : Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: d19b558d-xxxx-yyyy-zzzz-cfc3bb1a3501; Reason: (Partition key path /id is invalid for MongoDB API.

Do I need to create something on the cloud side for the leases?