I am using azure function 1.0.13 SDK with 1.2.0 DocumentDB extension. The following is the code that i am trying to run:
[FunctionName("Function1")]
public static void Run([CosmosDBTrigger(
databaseName: "database",
collectionName: "collection",
ConnectionStringSetting = "DBConn",
LeaseCollectionName = "leases")]IReadOnlyList<Document> documents, TraceWriter log)
{
if (documents != null && documents.Count > 0)
{
log.Verbose("Documents modified " + documents.Count);
log.Verbose("First document Id " + documents[0].Id);
}
}
Now when I try debugging locally in VS, I get the following error:
Function1: The listener for function 'Function1' was unable to start. Microsoft.Azure.WebJobs.Extensions.DocumentDB: Either the source collection 'database' (in database 'database') or the lease collection 'leases' (in database 'database') does not exist. Both collections must exist before the listener starts. To automatically create the lease collection, set 'CreateLeaseCollectionIfNotExists' to 'true'. Microsoft.Azure.Documents.Client: Message: {"Errors":["Resource Not Found"]}
[6/26/2018 3:24:49 PM] ActivityId: 7738cc1a-f8f6-45a2-a3c6-73d342a8d4c3, Request URI: /apps/4c8d65d7-216b-46b4-abb7-52c1a0c7123f/services/b3a1db8d-b82c-403e-8d89-9709b5068482/partitions/0a2bdc5c-471b-4acc-a093-6332c8ce1d5d/replicas/131727365611181690s, RequestStats: [6/26/2018 3:24:49 PM] ResponseTime: 2018-06-26T15:24:48.5014600Z, StoreReadResult: StorePhysicalAddress: rntbd://10.98.106.50:11000/apps/4c8d65d7-216b-46b4-abb7-52c1a0c7123f/services/b3a1db8d-b82c-403e-8d89-9709b5068482/partitions/0a2bdc5c-471b-4acc-a093-6332c8ce1d5d/replicas/131727365611181690s, LSN: 125, GlobalCommittedLsn: 125, PartitionKeyRangeId: , IsValid: True, StatusCode: 0, IsGone: False, IsNotFound: True, IsInvalidPartition: False, RequestCharge: 1, ItemLSN: -1, ResourceType: Collection, OperationType: Read [6/26/2018 3:24:49 PM] ResponseTime: 2018-06-26T15:24:48.5014600Z, StoreReadResult: StorePhysicalAddress: rntbd://10.98.108.179:11000/apps/4c8d65d7-216b-46b4-abb7-52c1a0c7123f/services/b3a1db8d-b82c-403e-8d89-9709b5068482/partitions/0a2bdc5c-471b-4acc-a093-6332c8ce1d5d/replicas/131727455073557671s, LSN: 125, GlobalCommittedLsn: 125, PartitionKeyRangeId: , IsValid: True, StatusCode: 0, IsGone: False, IsNotFound: True, IsInvalidPartition: False, RequestCharge: 1, ItemLSN: -1, ResourceType: Collection, OperationType: Read [6/26/2018 3:24:49 PM] , SDK: Microsoft.Azure.Documents.Common/2.0.0.0.
I have copied and pasted the entire primary connection string from azure portal. I have checked multiple times to make sure that the database and collection names are found.
"database" and "collection" were modified for security reason.
What did I do wrong?