0

Is there any integration between CosmosDB and Api Apps? I'm kinda new in Azure and I don't really understand which is the best approach.

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. 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. Should I use the Api Apps or the integrated SQL Apis that are provided with CosmosDB? 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?

Thanks a lot in advance!

1
  • There is a javascript SDK in preview Commented Dec 10, 2018 at 18:36

1 Answer 1

1

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.

You can then use the Cosmos DB Input Binding to retrieve the object you want to return and simply return the JSON of it.

Sign up to request clarification or add additional context in comments.

5 Comments

A great idea. I didn't know about http triggers, you opened a world for me. Tomorrow I'm going to try it out, will update if I get into any other problems. Thanks a lot again!
Glad I helped :)
Sorry if I bother you once more but I have one final question: would you recommend an Azure Function with an Http trigger for a moderately big project and, in your experience, is it easier/most efficient to deploy this kind of system or a more standard one in a production environment? Thanks a lot again for the help!
@Eugenio Depends on what you mean by "big project". Azure Functions are meant to execute small operations but this doesn't mean you can't build a big project on them. An example would be Troy Hunt's haveibeenpwned which actually runs on HTTP Trigger based Azure Functions and serves some billion requests with no problems. (Ofc caching is also involved but that's with any site).
Great explanation, thanks a lot for the help! Really appreciate it!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.