Azure learning error: Can't bind CosmosDB to type 'System.String'

Łukasz Opasiak 31 Reputation points
2020-06-02T14:40:39.517+00:00

While doing the https://learn.microsoft.com/en-gb/learn/modules/chain-azure-functions-data-using-bindings/, "Exercise - Read data with input bindings", I'm getting error

> 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.

Everything is set correctly, exactly the same as specified in the tutorial (I've done it x3 to be sure).

Seems like a bug to me.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,644 questions
Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,535 questions
0 comments No comments
{count} votes

5 additional answers

Sort by: Most helpful
  1. Barcellos Ryff, João Alberto 26 Reputation points
    2020-06-09T21:46:45.977+00:00

    Removes the "sqlQuery": "" from your function.json file

    5 people found this answer helpful.
    0 comments No comments

  2. Stefan Walter 16 Reputation points
    2020-06-29T19:15:30.023+00:00

    You have to remove manually the "sqlQuery": "" line from your binding in your file function.json. Afterward, your HTTP result code of 500 should change to 200.

    Working Sample:

    {
          "name": "bookmark",
          "direction": "in",
          "type": "cosmosDB",
          "databaseName": "func-io-learn-db",
          "collectionName": "Bookmarks",
          "connectionStringSetting": "exercise-app-sw1980_DOCUMENTDB",
          "id": "id",
          "partitionKey": "id"
    }
    
    3 people found this answer helpful.

  3. Lein Ton 11 Reputation points
    2020-06-03T09:17:04.943+00:00

    Looks like the CosmosDB input binding doesn't keep its configuration.

    I had the same issue, edited the binding's config in function.json (removed the empty sqlquery and updated "id" to "Id".)
    Then checked the CosmosDB input connection on the integration screen and found it empty.
    After filling in the details again, the function started working.

    2 people found this answer helpful.

  4. Leon Laude 85,721 Reputation points
    2020-06-02T14:42:41.447+00:00

    Hi,

    Q&A currently supports the products listed over here https://learn.microsoft.com/en-us/answers/products (more to be added later on).

    You can reach the experts in the dedicated "Microsoft Learning - Microsoft Azure Training" forum over here:
    https://trainingsupport.microsoft.com/en-us/tcml/forum/tcml_mat

    (Please don't forget to accept helpful replies as answer)

    Best regards,
    Leon

    0 comments No comments