CosmosDB 休息 API - Http 请求

CosmosDB Rest API - Http Request

是否可以在 Azure Cosmos 中以 JSON 格式检索我的数据并与其他人共享,而无需他们访问实际环境?类似于 HTTP 从共享点获取的东西。我是 cosmos 和 API 的新手,如果我在这里使用了错误的术语,我深表歉意。

更新尝试 Azure 函数:

我试图创建一个 HTTPTrigger。我可以将 JSON 复制并粘贴到 function.json 并将 javascript 复制并粘贴到 index.js 中吗?我更改了 databaseName 和 collectionName,但它没有 return cosmos 文档。

一般

我认为向某人提供对指定集合的​​访问权限的最简单方法是创建一个 Azure 函数。来自文档:

Azure Functions allows you to run small pieces of code (called "functions") without worrying about application infrastructure. With Azure Functions, the cloud infrastructure provides all the up-to-date servers you need to keep your application running at scale.

A function is "triggered" by a specific type of event. Supported triggers include responding to changes in data, responding to messages, running on a schedule, or as the result of an HTTP request.

C#

如果您希望通过 id 查询文档,下面是一个示例:

https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-cosmosdb-v2-input?tabs=csharp#http-trigger-look-up-id-from-query-string

如果要执行更复杂的查询,请查看上述文档的这一部分:

https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-cosmosdb-v2-input?tabs=csharp#http-trigger-look-up-id-from-route-data-using-sqlquery

所以基本上这使您能够提供一个 HTTP 端点,该端点被配置为针对您的 CosmosDB 实例 运行 特定查询。

JavaScript

有关如何在 JS 中设置 CosmosDB 实例和为 CRUD 操作创建函数的示例,请参见此处: https://dev.to/vidamrr/cosmos-db-crud-operations-using-azure-functions-4d27