azure - "Not available: couldn' t 连接到您的应用程序“实时指标 Azure Application Insights

标签 azure azure-application-insights azure-monitoring

我有 .Net Framework 4.7.2 中的 Web 应用程序。它在 Azure 中部署为应用程序服务。我已经在其中启用了应用程序洞察。我可以阅读日志。但是当我点击“实时指标”时,它显示“不可用:无法连接到您的应用程序” enter image description here

我在应用程序中添加了“Microsoft.ApplicationInsights”的最新包。同样在 Azure 门户中,在该应用服务中,在配置中添加了应用设置“APPINSIGHTS_INSTRUMENTATIONKEY”、“APPLICATIONINSIGHTS_CONNECTION_STRING”。

我还查看了 Microsoft 疑难解答文章“无法连接到您的应用程序的疑难解答”,但已执行该文章中提到的步骤。

我无法找到无法连接到应用程序的原因。有人可以帮我解决这个问题吗?

最佳答案

当您在 Azure 门户中创建应用服务时,它还将创建 App Insights 资源:

enter image description here

在发布网站之前,您必须将 Web 应用程序连接到关联的 App Insights 资源:
enter image description here

当您运行 Web 应用程序(打开 URL)时,请求率、时间将显示在实时指标中。正如您在下面的 Gif 中看到的,它显示了请求率、刷新主页的时间:

enter image description here

enter image description here

注意:

  1. 检查 Web.Config 文件 > 配置部分中是否有与 Application Insights 相关的包:
 <system.web>
    <compilation debug="true" targetFramework="4.7.2" />
    <httpRuntime targetFramework="4.7.2" />
    <httpModules>
      <add name="TelemetryCorrelationHttpModule" type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation" />
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
    </httpModules>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules>
      <remove name="TelemetryCorrelationHttpModule" />
      <add name="TelemetryCorrelationHttpModule" type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation" preCondition="managedHandler" />
      <remove name="ApplicationInsightsWebTracking" />
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
    </modules>
  </system.webServer>

Packages.config 文件代码:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Microsoft.ApplicationInsights" version="2.22.0-beta1" targetFramework="net472" />
  <package id="Microsoft.ApplicationInsights.Agent.Intercept" version="2.4.0" targetFramework="net472" />
  <package id="Microsoft.ApplicationInsights.DependencyCollector" version="2.22.0-beta1" targetFramework="net472" />
  <package id="Microsoft.ApplicationInsights.PerfCounterCollector" version="2.22.0-beta1" targetFramework="net472" />
  <package id="Microsoft.ApplicationInsights.Web" version="2.22.0-beta1" targetFramework="net472" />
  <package id="Microsoft.ApplicationInsights.WindowsServer" version="2.22.0-beta1" targetFramework="net472" />
  <package id="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" version="2.22.0-beta1" targetFramework="net472" />
  <package id="Microsoft.AspNet.TelemetryCorrelation" version="1.0.8" targetFramework="net472" />
  <package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="4.1.0-preview1" targetFramework="net472" />
  <package id="System.Buffers" version="4.5.1" targetFramework="net472" />
  <package id="System.Diagnostics.DiagnosticSource" version="7.0.0" targetFramework="net472" />
  <package id="System.Memory" version="4.5.5" targetFramework="net472" />
  <package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
  <package id="System.Runtime.CompilerServices.Unsafe" version="7.0.0-preview.2.22152.2" targetFramework="net472" />
</packages>

引用这个MS Doc了解更多信息。

关于azure - "Not available: couldn' t 连接到您的应用程序“实时指标 Azure Application Insights,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75106329/

相关文章:

Azure 函数监视器警报,其中执行计数 < 1 从未触发

c# - Azure消息总线异步检索数据并通过 Controller 操作返回数据

azure-stream-analytics - Application Insights 和 Azure 流分析查询自定义 JSON 属性

azure - 显示同一方法的不同记录的性能图 block

azure - TrackRequest() 数据显示在门户中的什么位置?

c# - 如何将异常链接到 Azure 上的 Application Insights 中的请求?

azure - 使用门户中的 app() 表达式进行跨资源查询, “The following application isn’ t 不再可用”

python - 如何使用python从容器中下载所有blob,其中blob是子目录样式

asp.net-mvc - 为什么 System.Web.Services.Protocols.LogicalMethodInfo 无法在 Azure 缓存中序列化?

sql-server - Azure 数据仓库和 Microsoft 并行数据仓库 (PDW) 之间的差异