0

I've created a webapp where most of the processing is done by the users browser using Javascript. For it's development I've used locally stored JSON docs but I need to be able store these in an Azure Cosmos DB.

I'm struggling to understand how to create an Azure function where I can do AJAX calls to the function, which is then passed on to the DB. I've been playing with node.js and express but how do you link DocumentDB module and expose that to another module that can provide AJAX requests?

I've tried looking through Microsofts examples but they are huge, pulling in loads of modules and trying to reverse engineer them and understand how they work is almost impossible for a newbie like me. Can any point in the right direction? Happy to learn and read up but I've not found anything on Google despite spending all day looking.

pixie
  • 55
  • 8
  • If you're using Node and Express, you'd still need to add a library for the doc db like Mongoose or Nano. Try reading up on those or on NPM just search for the db of your choice. There are plenty of examples on how to accomplish what you're trying to do. – Marc M. Dec 03 '18 at 20:21
  • Thanks Marc, the connection module is called DocumentDB, sorry I should have been clearer. Do you have any specific resources you can point me to? I found lots of sites that had lots of code without any explanation, which didn't cover my specific use case. The lack of explanation to the code made it very hard for me to be able to understand or modify it – pixie Dec 03 '18 at 20:41
  • Hi Pixie! Take a look here for the overview https://www.npmjs.com/package/documentdb They do also have a link to codee samples there too. – Marc M. Dec 03 '18 at 20:46

1 Answers1

1

More research (and coffee) today. The way I've figured this out is follow this SkillShare course

Using the code function in Postman (set to JavaScript XHR) will give you the AJAX calls and following the link Marc gave in the comments to my question will allow you to swap the Mongoose package for the DocumentDB package. Then it's just a case of writing functions and a user interface around this.

I'm going to start by building a user interface page for the courses CRUD app as a prototype before looking to translate this to DocumentDB.

pixie
  • 55
  • 8