Skip to content

Latest commit

 

History

History
26 lines (20 loc) · 813 Bytes

README.md

File metadata and controls

26 lines (20 loc) · 813 Bytes

PingIoTContdFunctions

#r "Newtonsoft.Json"

using System;
using Newtonsoft.Json;
using System.Threading.Tasks;

public static string Run(string mySbMsg, TraceWriter log)
{
    log.Info($"C# ServiceBus topic trigger function processed message: {mySbMsg}");
           dynamic MyData = JsonConvert.DeserializeObject(mySbMsg);

            DateTime functiondate = MyData.functiondate;
            MyData.storefunctiondate = DateTime.UtcNow;

            //calculate time difference from sent to received and write to console
            TimeSpan timedifference = DateTime.UtcNow - functiondate;
            double timespan = timedifference.Milliseconds;
            MyData.functiontimespan = timespan;

            string outmessage = JsonConvert.SerializeObject(MyData);
            return outmessage;
}