1

I have an Azure function that runs with a CosmosDBTrigger. It points correctly to my target database and collection. The CreateLeaseCollectionIfNotExists is set to true and the LeaseCollectionName is set to leases. When the function is started I receive this error:

Error indexing method ' * * ' Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexingException : Error indexing method '***' ---> System.InvalidOperationException : Cannot create Collection Information for *** in database *** with lease leases in database *** : Partition key path /id is invalid for Gremlin API. The path cannot be '/id', '/label' or a nested path such as '/key/path'

It seems like Azure is creating the leases graph with an '/id' as a partition. Where did I go wrong?

von v.
  • 16,868
  • 4
  • 60
  • 84

1 Answers1

0

The Azure Functions Cosmos DB Trigger documentation says it only works on SQL API accounts: https://learn.microsoft.com/azure/azure-functions/functions-bindings-cosmosdb-v2#supported-apis

Particularly the Trigger uses the Change Feed Processor library that was designed to work with SQL API accounts, it uses a lease collection that has the requirement of being partitioned by /id which is something that Gremlin API accounts cannot do.

Matias Quaranta
  • 13,907
  • 1
  • 22
  • 47
  • Thanks. But that is about binding and I'm not using any. I edited my question and removed COLLECTION_NAME and DATABASE_NAME as those are just placeholders in my question - not the actual names in my Cosmos account. I have another database and collection in the same account monitored by another function and it works fine. I already compared the two function apps and I can't see any difference why the other one is not working and the other one works just fine. – von v. Mar 24 '21 at 01:08
  • The documentation page has the title "Azure Cosmos DB trigger and bindings for Azure Functions 2.x and higher overview" so it applies to the binding AND trigger. The Trigger, if you are using the `CreateLeaseCollectionIfNotExists` configuration, will try to create the lease collection with `/id` as partition key, which is the requirement of the Change Feed Processor. Other Functions might be connecting to other accounts that are SQL API OR might be using lease collections that are already partitioned by `/id`. – Matias Quaranta Mar 24 '21 at 21:24
  • 1
    The error you are getting is coming from the Cosmos DB service, not from Functions or the Trigger. The Gremlin API backend is blocking the attempt to create the collection. This block might be something that was added to Gremlin API accounts recently and that could be the reason your other Functions are working (maybe the lease collections for those were created before the block was added, I wouldn't be able to say). – Matias Quaranta Mar 24 '21 at 21:25
  • 1
    your last statement makes the most sense. Thanks for sharing your knowledge, I appreciate you. – von v. Mar 25 '21 at 08:26