locked
CosmosDB with Mongo API failed to bind in Azure Function RRS feed

  • Question

  • Looks like you cannot bind output in Azure Function using CosmosDB with MongoDB API 

    For example, I am creating a Azure function with the Nodejs runtime.

    Here is the binding function.json

    {
          "type": "cosmosDB",
          "direction": "out",
          "name": "outputDocument",
          "databaseName": "test-database",
          "collectionName": "test",
          "createIfNotExists": "true",
          "connectionStringSetting": 
          "mydbconnection_DOCUMENTDB"
    }

    In my azure function I'm adding a new entry into the collection(which is running Mongo API) with below code

    context.bindings.outputDocument = JSON.stringify({
        test: "test insert",
      });

    However, function will failed with below exception

    [5/14/2020 6:47:16 PM] Executed 'Functions.test-trigger' (Failed, Id=22b39067-6d24-4040-8d5c-b61c9e257d00)
    [5/14/2020 6:47:16 PM] System.Private.CoreLib: Exception while executing function: Functions.test-trigger. Microsoft.Azure.DocumentDB.Core: Sql api is not supported for this database account
    [5/14/2020 6:47:16 PM] ActivityId: 185a9c06-6904-4019-8b1a-b75acc0e83fc, Microsoft.Azure.Documents.Common/2.11.0, Darwin/10.15 documentdb-netcore-sdk/2.3.0.

    Thursday, May 14, 2020 6:59 PM

All replies