Reputation: 213
i am working on the sample example provided by microsoft in the link below https://anthonychu.ca/post/cosmosdb-real-time-azure-functions-signalr-service/ I have followed all the steps by i am getting the error below while running the code with azure function locally:
The listener for function 'Functions.OnDocumentsChanged' was unable to start. [2/18/2019 9:50:54 PM] The listener for function 'Functions.OnDocumentsChanged' was unable to start. Microsoft.Azure.Documents.ChangeFeedProcessor: The lease collection, if partitioned, must have partition key equal to id
Upvotes: 2
Views: 661
Reputation: 15603
The error message is quite clear, the Trigger uses a secondary (Leases) collection to store the state. On your Trigger definition you can specify, on the Configuration if you want to specify a particular Leases collection name / database name or leave the default ("leases").
The Trigger can also create the Leases collection for you if it does not exist through the CreateLeaseCollectionIfNotExists
attribute.
In your case, you seem to already have the leases collection previously created.
The problem is that the leases collection, if it's partitioned, it needs to be by the /id
that is what the error message is saying:
The lease collection, if partitioned, must have partition key equal to id
So to fix this scenario you can either:
CreateLeaseCollectionIfNotExists = true
to let the Trigger create it for you./id
as the Partition Key.Upvotes: 2