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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -