Skip to content

Instantly share code, notes, and snippets.

@QiMata
Created March 9, 2018 00:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save QiMata/0514f72017622b4654ab551a20b2013a to your computer and use it in GitHub Desktop.
Save QiMata/0514f72017622b4654ab551a20b2013a to your computer and use it in GitHub Desktop.
[FunctionName("StreamOutputToElastic")]
public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequestMessage req, TraceWriter log)
{
var node = new Uri("http://{username}:{password}@{ipaddress}:9200");
var settings = new ConnectionSettings(node);
settings.DefaultIndex("my-index");
var elasticClient = new ElasticClient(settings);
var records = await req.Content.ReadAsAsync<T>();
await elasticClient.IndexManyAsync(timeStampedEvents, "my-index-name");
return req.CreateResponse(HttpStatusCode.OK);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment