Azure / Azure/Azure-Functions

"Can't figure out which ctor to call." error with CosmosDB trigger

Open
#2,447 12 comments 2 reactions 1 assignee Claimed by @bhagyshricompany View on GitHub
Needs: Author feedback
Dominant language
PowerShell
Stars
1.1k
Forks
215
Avg merge
4h 2m
Merged PRs (30d)
1

Description

I'm trying to run a new Function locally. It uses the CosmosDB trigger. Building works fine, but when trying to run with `func host start`, I get this error: **The 'companiesWrite' function is in error: Unable to configure binding 'cosmosDBTrigger1' of type 'cosmosDBTrigger'. This may indicate invalid function.json properties. Can't figure out which ctor to call.**

I see a similar issue here: https://github.com/Azure/Azure-Functions/issues/277. The problem was a misnamed configuration property. But I checked all of mine against both the TypeScript def and the online documentation.

My code:

```typescript
import { app, InvocationContext } from "@azure/functions";

export async function companiesWrite(documents: any[], context: InvocationContext): Promise {
context.log(`Cosmos DB function processed ${documents.length} documents`);
}

app.cosmosDB('companiesWrite', {
connectionStringSetting: 'devworksafetyindex_DOCUMENTDB',
databaseName: 'wsi',
collectionName: 'companies',
createLeaseCollectionIfNotExists: true,
maxItemsPerInvocation: 40,
handler: companiesWrite
});
```

My host.json:

```json
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[4.*, 5.0.0)"
}
}
```

I tried adding an HttpTrigger Function, and this worked fine. So it appears to be something specific to my CosmosDB trigger.

Thanks!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.