我必须让最多数量的城市浏览我的应用程序。我正在使用应用程序见解获取这些数据。不过,我想将该数据存储到一个数组中,并使用 SELENIUM c# 将其传递给测试函数。我在分析中使用以下查询。我安装了 app Insights nuget 包并连接到它。
customevents
| where timestamp >= ago(24h)
| summarize count() by client_City
| order by count_ desc
C# 代码:
TelemetryClient telemetry = new TelemetryClient();
telemetry.InstrumentationKey = "xxxx";
telemetry.TrackEvent("eventname");
我想将来自分析查询的数据存储到 C# 中的数组中。我们有什么办法可以做到吗?
最佳答案
使用TelemetryClient
,您只能写入数据,而不能查询数据。
您有以下选择:
- 例如,将数据导出到 Blob 存储或 Sql Server,并在其中创建一个可以使用 .Net 读取的查询 ( https://learn.microsoft.com/en-us/azure/application-insights/app-insights-export-telemetry#export-samples )
- 将问题中的查询数据导出到 CSV 文件并在 .Net 中读取该文件(这是手动操作)
- 使用 Application Insights REST Api 直接在 .Net 中查询数据。请参阅https://dev.applicationinsights.io/quickstart/ .
我认为选项 3 最适合您。
关于c# - 使用 C# 将应用程序洞察中的自定义事件数据获取到数组中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41378655/