-
Notifications
You must be signed in to change notification settings - Fork 496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Azure Function Isolated] Cosmos change feed listener tries to start before CreateContainerIfNotExistsAsync #3150
Comments
You might need to reach to Azure Functions. The Cosmos DB SDK does not dictate the order of how Azure Functions decides to load Functions or the Host and on which order. |
Closing as out of the scope of this repo. https://github.com/Azure/azure-functions-host might be a good candidate to ask how you can execute code before the runtime loads the declared Functions. |
After some digging might be this repo: https://github.com/Azure/azure-webjobs-sdk-extensions? |
@andersson09 that repo just contains the bindings and extension definitions but it does not govern the runtime initialization order. Extension only scope to what happens when the Extension initializes, but what you are trying to do is execute some code before they initialize. That would mean interacting with the Host lifecycle. |
@ealsur The error message is here https://github.com/Azure/azure-webjobs-sdk-extensions/blob/0683d1bd08a16680c70f982ad00c940b7e9c1fce/src/WebJobs.Extensions.CosmosDB/Trigger/CosmosDBTriggerListener.cs#L140 I'll add it to both in case. |
@andersson09 - Correct, but that error message is just the Extension saying that it cannot find the container, it has nothing to do with your intent to create the container before the Function is initialized. The Extensions start when the Host/Runtime tell them to start, they do not have control over when that happens. What is happening is that you have some code that you want to run before the Host signals the Extensions to start, but you are not able to put that code in a place where the Host is executing it before. The Host is starting the Extensions either at the same time or before your code. In order to know where to put your code to achieve what you want, you need guidance or at least someone that knows how the Function Host works. This is not the repo. |
For isolated azure functions, I believe that the cosmos change feed tries to listen before containers have been created. Either that or I'm doing something wrong?
Thanks
Setup:
Error message on local machine:
The listener for function 'DoSomething' was unable to start. Microsoft.Azure.WebJobs.Extensions.CosmosDB: Either the source collection 'container' (in database 'db') or the lease collection 'leases' (in database 'db') does not exist. Both collections must exist before the listener starts. To automatically create the lease collection, set 'CreateLeaseCollectionIfNotExists' to 'true'
Versions
Microsoft.Azure.Functions.Worker.Sdk 1.3.0
Microsoft.Azure.Functions.Worker.Extensions.Http 3.0.13
Microsoft.Azure.Cosmos 3.26.1
Microsoft.Azure.Functions.Worker.Extensions.CosmosDB 3.0.9
The text was updated successfully, but these errors were encountered: