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

Łukasz Opasiak 31 Reputation points

While doing the, "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=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' but user type assembly was 'System.String, System.Private.CoreLib, Version=, 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

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

    5 people found this answer helpful.
    0 comments No comments

  2. Stefan Walter 16 Reputation points

    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

    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


    Q&A currently supports the products listed over here (more to be added later on).

    You can reach the experts in the dedicated "Microsoft Learning - Microsoft Azure Training" forum over here:

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

    Best regards,

    0 comments No comments