json - How to Save multiple messages in Azure Function JavaScript? -


i have created 1 azure function in azure app triggered iot hub, , saves received messages in sql database. not able handle when receives multiple messages. function bellow.

module.exports = function (context, iothubmessage) {  (var = 0; < iothubmessage.length; i++) {      var iotmsgobj = iothubmessage[i];     context.log('message : ' + json.stringify(iotmsgobj));      context.bindings.parasession = json.stringify(iotmsgobj);   //to save data in sql database      context.done();         //  save first message }  // context.done();     // save last message  }; 

when iothubmessage hub has multiple json objects, save ether first or last message iothubmessage store in database table.

please advice doing wrong?

i haven't tried sql binding, returning array works other types (e.g. queue):

module.exports = function (context, iothubmessage) {    context.bindings.parasession = [];   (var = 0; < iothubmessage.length; i++) {     var iotmsgobj = iothubmessage[i];     context.bindings.parasession.push(json.stringify(iotmsgobj));   }    context.done(); }; 

Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -