简体   繁体   English

Azure-Cosmos DB与API应用程序集成

[英]Azure - Cosmos DB integration with API Apps

Is there any integration between CosmosDB and Api Apps? CosmosDB和Api Apps之间是否有任何集成? I'm kinda new in Azure and I don't really understand which is the best approach. 我是Azure的新手,我不太了解哪种方法最好。

My problem is that I am working on an IoT Project which gets data from the IoT Hub, passes it to a Function that sends it to the CosmosDB which then would need to be consumed by a Frontend. 我的问题是我在一个IoT项目上工作,该项目从IoT中心获取数据,并将其传递给Function,该函数将其发送到CosmosDB,然后前端需要使用它。 A pretty standard case. 一个相当标准的案例。

I would usually create a backend to place between the database and the frontend but I really can't understand which is the best way to do it in Azure. 我通常会创建一个后端来放置在数据库和前端之间,但是我真的不明白哪种方法是在Azure中实现的最佳方法。 Should I use the Api Apps or the integrated SQL Apis that are provided with CosmosDB? 我应该使用CosmosDB随附的Api Apps还是集成的SQL Apis? Are the Api Apps comparable to "containers" for my backend or do they have any other use other than keeping my code in a cloud machine? 对于我的后端而言,Api Apps是否可与“容器”媲美,或者除了将我的代码保存在云机中之外,它们还有其他用途吗?

Thanks a lot in advance! 在此先多谢!

You can't (well, shouldn't) have your frontend to directly call the database so you need a middle layer of some sort. 您不能(或者不应该)让前端直接调用数据库,因此您需要某种中间层。

Creating an API could be one of the ways you go about it but based on your use-case, I would go with an HTTP Trigger Azure Function which would be the API that exposes the data. 创建API可能是您使用它的一种方式,但是根据您的用例,我将使用HTTP触发器Azure函数 ,它将是公开数据的API。

You can then use the Cosmos DB Input Binding to retrieve the object you want to return and simply return the JSON of it. 然后,您可以使用Cosmos DB输入绑定来检索要返回的对象,并仅返回其JSON。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM