I'm not aware of a Nuget package that encapsulates this, but App Insights has a REST API that they expose and they have an API Quickstart guide
The C# example is included below:
private const string URL =
"https://api.applicationinsights.io/v1/apps/{0}/{1}/{2}?{3}";
public static string GetTelemetry(string appid, string apikey,
string queryType, string queryPath, string parameterString)
{
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Add("x-api-key", apikey);
var req = string.Format(URL, appid, queryType, queryPath, parameterString);
HttpResponseMessage response = client.GetAsync(req).Result;
if (response.IsSuccessStatusCode)
{
return response.Content.ReadAsStringAsync().Result;
}
else
{
return response.ReasonPhrase;
}
}
...
var json = GetTelemetry
("DEMO_APP", "DEMO_KEY",
"metrics", "requests/duration", "interval=PT1H");
The example call at the bottom will return request duration aggregated per hour for the past 24 hours (default timeframe for the example route).
Creating the API keys can be done via the API Access menu, under the Configuration heading for each specific Application Insights instance:
