Created
August 14, 2016 16:28
-
-
Save trondhindenes/46096c6054a67e8b29377300ffb74345 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Newtonsoft.Json; | |
using Newtonsoft.Json.Linq; | |
using System.Net; | |
public static void Run(string myEventHubMessage, TraceWriter log) | |
{ | |
String data = myEventHubMessage; | |
log.Info($"C# Event Hub trigger function processed a message: {data}"); | |
data = data.Replace("http://schemas.microsoft.com", ""); | |
data = data.Replace("http://schemas.xmlsoap.org", ""); | |
JToken token = JObject.Parse(data); | |
//var parsedData = format_json(data); | |
string url = "http://<my_logstash_server>"; | |
foreach (var record in token.SelectToken("records")) | |
{ | |
Console.WriteLine("record:--------------------------------------------------------------------"); | |
Console.WriteLine(record.ToString()); | |
string result = ","; | |
using (var client = new WebClient()) | |
{ | |
client.Headers[HttpRequestHeader.ContentType] = "application/json"; | |
result = client.UploadString(url, "POST", record.ToString()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment