[英]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.