简体   繁体   English

如何从我的 azure cosmos db 中查询数据?

[英]How can i query data from my azure cosmos db?

I have azure functions written in nodejs.我有用 nodejs 编写的 azure 函数。 I can't find a way how to get data for example from my created azure cosmos db.例如,我找不到如何从我创建的 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.我知道有 azure cosmos SDK,但我不想用那种方式。我想通过 azure 函数来学习。

i try do to this:我尝试这样做:

function.json 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.部署后,当我访问自动生成的 url - 我什至无法打开链接。没有请求返回。

If i do some basic example where i don't try to pull data from the db then my url is working after deploy.如果我做了一些基本示例,我不尝试从数据库中提取数据,那么我的 url 在部署后工作。

How can i get the data?我怎样才能得到数据?

My data in the local.settings.json was wrong.我在 local.settings.json 中的数据是错误的。 I had azure storage for other table not for the one that i wanted to query... The code works perfectly fine我有 azure 存储用于其他表而不是用于我想查询的表......代码工作得很好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在特定阶段将数据从 azure cosmos db 备份到 azure blob? - How do I backup data to azure blob from azure cosmos db during a specific stage? 是否可以使用变量从 function 中动态调用 SQL 查询 Azure 函数的 Cosmos DB 输入绑定? - Can the SQL query for an Azure Function's Cosmos DB input binding be called dynamically, with variables, from within the function? 无法从Azure Cosmos DB上的mongodb中获取所有文档 - Can't fetching all documents from my mongodb on Azure Cosmos DB 如何通过Node App监听Azure Cosmos DB中的数据库更改 - How to listen to DB changes in Azure Cosmos DB from Node App 如何使用 Node.js 在 Azure Cosmos DB 中执行 SQL 查询 - How Execute SQL Query in Azure Cosmos DB with Node.js 如何在 Azure Cosmos DB 中使用 Gremlin API 将数据作为 JSON 对象插入 - How to insert data as JSON object with Gremlin API in Azure Cosmos DB 如何使用带有HTTP触发器POST的Azure函数在Cosmos Azure(NOSQL)中更新数据 - How can i update data in Cosmos Azure (NOSQL) , using Azure function with HTTP trigger POST 在 Azure 函数和 Cosmos DB 中使用查询参数 - Using query params in Azure functions and Cosmos DB 如何使用 Cosmos DB 触发器构建 Azure 函数? - How to build an Azure Function with Cosmos DB Trigger? 基于时间戳Azure存储表/ Azure Cosmos DB进行查询 - Query on the basis of Timestamp Azure Storage Table/Azure Cosmos DB
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM