c# - 使用 C# 将应用程序洞察中的自定义事件数据获取到数组中

标签 c# azure azure-application-insights

我必须让最多数量的城市浏览我的应用程序。我正在使用应用程序见解获取这些数据。不过,我想将该数据存储到一个数组中,并使用 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,您只能写入数据,而不能查询数据。

您有以下选择:

  1. 例如,将数据导出到 Blob 存储或 Sql Server,并在其中创建一个可以使用 .Net 读取的查询 ( https://learn.microsoft.com/en-us/azure/application-insights/app-insights-export-telemetry#export-samples )
  2. 将问题中的查询数据导出到 CSV 文件并在 .Net 中读取该文件(这是手动操作)
  3. 使用 Application Insights REST Api 直接在 .Net 中查询数据。请参阅https://dev.applicationinsights.io/quickstart/ .

我认为选项 3 最适合您。

关于c# - 使用 C# 将应用程序洞察中的自定义事件数据获取到数组中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41378655/

相关文章:

c# - 单击其他单元格时如何获取文本框中gridview的单元格值?

c# 具有通用项的接口(interface)列表

c# - ASP.NET Timer 只在 Debug模式下工作

c# - 通用列表的标准偏差?

.net - Azure Service Fabric 使用 log4net 将日志记录到 AppInsights 中

javascript - 如何将 JSON 导入到 Cosmos DB

azure - Hive 表迁移到不同的环境

c# - 如何跟踪 LUIS 服务的每个最终用户的配额使用情况?

python - 天蓝色函数 : How do I write my logs to Azure Application Insights using local debug mode with Azure Functions using Python?

azure - 如何从 Application Insights 存储桶中清除记录?