— JavaScript, Azure — 1 min read
This one was a pesky annoying issue that ate up a lot of my time. The solution was just deletion of a line. I couldn't find the exact issue on stackoverflow, but there were some hints. Like generated JSON has issues.
While following Azure Documentation on connecting Azure function with Cosmos DB, I ran into following error.
1[2021-10-29T19:05:02.795Z] The 'HttpTrigger1' function is in error: Unable to configure binding 'outputDocument' of type 'cosmosDB'. This may indicate invalid function.json properties. Input string was not in a correct format.
The issue was with generated function.json
file, I had to snip out the following to get it working
1"collectionThroughput": ""
So the final node looked something like
1{2 "type": "cosmosDB",3 "direction": "out",4 "name": "outputDocument",5 "databaseName": "my-database",6 "collectionName": "my-container",7 "createIfNotExists": false,8 "connectionStringSetting": "CosmosDbConnectionString",9 "partitionKey": "{id}"10}
Azure should update the code generation logic or the document https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-cosmosdb-v2-output?tabs=javascript