Share via

Can't bind comsosdb input with Http trigger

piyush trivedi 121 Reputation points
2020-06-09T21:18:19.197+00:00

I have created HTTP trigger in javascript and trying to bind with cosmos db as describe here but I keep getting below error, can someone take a look into it, thanks.

https://learn.microsoft.com/en-us/learn/modules/chain-azure-functions-data-using-bindings/5-read-data-with-input-bindings-portal-lab?pivots=javascript

Can't bind CosmosDB to type 'System.String'. Possible causes: 1) Tried binding to 'Microsoft.Azure.Documents.Client.DocumentClient, Microsoft.Azure.DocumentDB.Core, Version=2.9.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' but user type assembly was 'System.String, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e.

Azure Functions
Azure Functions

An Azure service that provides an event-driven serverless compute platform.

0 comments No comments

Answer accepted by question author

piyush trivedi 121 Reputation points
2020-06-10T03:17:20.663+00:00

looks like some reference is missing but I found an alternative solution,

1: just go to classic way and retry configuration & save it, if this doesn't work then

2: go to cosmos DB, from there select function and then create a new function with the type of language, in my case I selected javascript and create the function, from there it will prompt you to a classic way of displaying function.
a) now verify the connection of your actual function which was not working even though everything looks okay to try to save again and then try, it will work!

Was this answer helpful?

1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Ivan P 21 Reputation points
    2020-06-15T22:05:17.993+00:00

    The issue for me was in function.json, containing
    "sqlQuery": ""

    Removing the line in the file and saving it did not work. I had to go into the input edit UI, enter some text into the SQL Query field, Save it. Then, go into the function.json file remove the sqlQuery line, and safe the file.

    Was this answer helpful?

    4 people found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.