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,263 questions
Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,442 questions
0 comments No comments
{count} votes

5 additional answers

Sort by: Most helpful
  1. VU LE 1 Reputation point
    2021-05-17T09:14:51.917+00:00

    The value for id, partitionKey should be {id} to make it work
    You should update the values in function.json like this:

     } 
           "name": "bookmark", 
           "direction": "in", 
           "type": "cosmosDB", 
           "databaseName": "func-io-learn-db", 
           "collectionName": "Bookmarks", 
           "connectionStringSetting": "exercise-app-sw1980_DOCUMENTDB", 
           "id": "{id}", 
           "partitionKey": "{id}" 
     } 
    
    0 comments No comments