-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.csx
45 lines (41 loc) · 1.47 KB
/
run.csx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#r "Microsoft.ServiceBus"
using System;
using System.Net;
using System.Reflection;
using System.Text;
using Microsoft.ServiceBus.Common;
using Microsoft.ServiceBus.Messaging;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.ApplicationInsights.Extensibility;
using Newtonsoft.Json;
class Record {
public string time;
public string resourceId;
public string operationName;
public string durationMs;
public string correlationId;
public string properties;
}
class EventHubMessage {
public Record[] records;
}
public static void Run(EventData myEventHubMessage, TraceWriter log)
{
TelemetryClient telemetry = new TelemetryClient();
telemetry.InstrumentationKey = "<INSTRUMENTATION_KEY_OF_APPLICATION_INSIGHT>";
string messageBody = System.Text.Encoding.UTF8.GetString(myEventHubMessage.GetBytes());
EventHubMessage ehm = JsonConvert.DeserializeObject<EventHubMessage>(messageBody);
foreach(Record record in ehm.records) {
var properties = new Dictionary<string, string>()
{
{"time", record.time},
{"resourceId", record.resourceId},
{"operationName", record.operationName},
{"durationMs", record.durationMs},
{"correlationId", record.correlationId},
{"properties", record.properties}
};
telemetry.TrackEvent("E2EDiagnostics", properties);
}
}