sdsd
sdsd

Reputation: 517

How can i query data from my azure cosmos db?

I have azure functions written in nodejs. I can't find a way how to get data for example from my created azure cosmos db. I know that there is azure cosmos SDK, but i don't want to use that way.I want to learn to do it through the azure functions because it is possible with them also.

i try do to this:

function.json

{
  "bindings": [
    {
      "authLevel": "anonymous",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "methods": [
        "get"
      ]
    },
    {
      "type": "http",
      "direction": "out",
      "name": "res"
    },
    {
      "type": "cosmosDB",
      "name": "inputDocument",
      "databaseName": "dbtodos",
      "collectionName": "items",
      "connectionStringSetting": "todos_DOCUMENTDB",
      "partitionKey": "/all",
      "direction": "in"
    }
  ],
  "disabled": false
}

index

module.exports = async function (context, req) {

    context.res = {
            // status: 200, /* Defaults to 200 */
            body: context.bindings.inputDocument
        };
};

after my deploy when i visit the automatically generated url - i can't even open the link.There is not requests coming back.

If i do some basic example where i don't try to pull data from the db then my url is working after deploy.

How can i get the data ?

Upvotes: 0

Views: 133

Answers (1)

sdsd
sdsd

Reputation: 517

My data in the local.settings.json was wrong. I had azure storage for other table not for the one that i wanted to query... The code works perfectly fine

Upvotes: 0

Related Questions