Reputation: 12423
Writing trace events to Applications Insights is extremely easy on any platform. For example, in C# under dotnet core it is:
Client.InstrumentationKey = InstrumentationKey;
Client.TrackTrace("Test Trace from DotNet Console App.");
But reading that data back appears to have no such simple API, at least via NuGet.
I have seen the documentation for Kusto:
https://learn.microsoft.com/en-gb/azure/kusto/api/netfx/about-kusto-ingest
But the closest I've come to simply and easily reading trace events is by reading the documentation for the API Explorer and converting that into dotnet core C#:
using (var client = new HttpClient(new HttpClientHandler {}))
{
client.DefaultRequestHeaders.Add("x-api-key", ApiKey);
var response = client.GetAsync(InsightsUrl).Result;
var succ = response.IsSuccessStatusCode;
var body = response.Content.ReadAsStringAsync().Result;
var path = $@"{AppDomain.CurrentDomain.BaseDirectory}..\..\..\Insights.json";
File.WriteAllText(path, body);
}
What is a comparably easy method to use for reading Insights trace (etc) events without having to build a web client?
Upvotes: 0
Views: 391
Reputation: 29940
Actually, no other simple ways like 1 or 2 line method for reading the trace(and other telemetry data) back.
As of now, the web api you used is the best way to achieve that.
Upvotes: 1