SandeshR
SandeshR

Reputation: 213

Integration of CosmosDB with Azure fuction and SignalR

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

enter image description here

Upvotes: 2

Views: 661

Answers (1)

Matias Quaranta
Matias Quaranta

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:

  1. Delete your current leases collection and use CreateLeaseCollectionIfNotExists = true to let the Trigger create it for you.
  2. Manually create your leases collection and set /id as the Partition Key.

Upvotes: 2

Related Questions