Skip to content

hybridflux/PingIoTContdFunctions

Repository files navigation

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;
}

About

Use Azure Functions to process a json messsage

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages