【问题标题】:Azure AppInsight not working for static file applicationAzure AppInsight 不适用于静态文件应用程序
【发布时间】:2019-01-25 00:03:34
【问题描述】:

背景

我有一个 Azure“应用服务”资源和一个链接的“Application Insights”资源。它们通过应用服务的Settings -> Applications settings -> Application settings (key-value table) 链接,我有以下设置:

  • APPINSIGHTS_INSTRUMENTATIONKEY = <my application insights instrumentation key>
  • APPINSIGHTS_JAVASCRIPT_ENABLED = true

我的应用程序是根 / (site\wwwroot) 的静态文件应用程序,但在 2 个不同的虚拟目录中也有 2 个 Asp.NET 应用程序:

  • /app1 (site\app1)
  • /app2 (site\app2)

问题

概览页面显示了包含请求、数据等的“指标”数据(第一张图片),但是当我尝试访问 Application Insights 时,没有显示任何数据(第二张图片)。

尝试

我已尝试按照以下两个指南来激活静态页面应用程序的应用洞察:

但是,由于根 Bin 文件夹中的 DLL 错误,我收到错误消息。 我尝试了以下变体:

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true"> <!-- With and without 'runAllManagedModulesForAllRequests'. -->

        <add name="ApplicationInsightsWebTracking"
            type="Microsoft.ApplicationInsights.Extensibility.Web.RequestTracking.WebRequestTrackingModule, Microsoft.ApplicationInsights.Extensibility.Web" 
            preCondition="managedHandler" /> <!-- With and without 'preCondition="managedHandler"'. -->

        <!-- And -->

        <add name="ApplicationInsightsWebTracking" 
            type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
            preCondition="managedHandler"/> <!-- With and without 'preCondition="managedHandler"'. -->

    </modules>
</system.webServer>

根据第二篇文章,一旦 Azure 知道它已连接到 AppInsight,这些缺失的 DLL 应该会自动加载。

如果您使用的是 Azure Web 应用程序。 Add the Applications Insights Extension to the Web App。这会将正确的 DLL 添加到您网站的 Bin 目录中。

我尝试按照“监控实时 Azure Web 应用”下的说明进行操作,但文档似乎不完整。

问题

  1. 为什么数据显示在应用服务的概述中,而不显示在 AppInsight 中?
  2. 是否可以在 AppInsight 中查看位于根 / 的静态文件应用程序的网站遥测数据?

【问题讨论】:

    标签: azure iis azure-application-insights


    【解决方案1】:

    1.为什么App Service的概览中显示的是数据,而不是AppInsight?

    应该是配置问题。你可以配置如下:

    第 1 步: 在 Visual Studio 中,右键单击您的项目名称,然后在上下文菜单中选择“配置 Application Insights”。

    第 2 步: 在以下屏幕中,单击“开始”。

    第 3 步: 在以下屏幕中,配置您自己的设置(对于资源,您可以创建新设置或使用现有设置)。 然后点击“注册”,等待完成。

    第 4 步: 如果出现一些错误,只需通过屏幕上的提示进行修复。如下所示:

    完成上述步骤后,您应该会在 App Insight 中看到数据(显示数据可能需要几分钟时间)。

    2.是否可以在 AppInsight 中查看我在根 / 的静态文件应用程序的网站遥测数据?

    是的,您可以在 AppInsight 中查看网站遥测数据以获取根目录下的静态文件应用程序。

    第 1 步: 在Web.config中找到&lt;system.webServer&gt;节点,然后在&lt;modules&gt;节点中添加runAllManagedModulesForAllRequests="true",如下图:

    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true">
          <remove name="TelemetryCorrelationHttpModule" />
          <add name="TelemetryCorrelationHttpModule" type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation" preCondition="integratedMode,managedHandler" />
          <remove name="ApplicationInsightsWebTracking" />
          <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
        </modules>
        <validation validateIntegratedModeConfiguration="false" />
    </system.webServer>
    

    第 2 步: 将网站发布到 azure。

    第 3 步: 将网站启动到静态文件,这里我以 test4.html 为例。

    第 4 步: 转到Azure门户->您的应用程序->概述部分,选择“服务器请求”之类的图表(如果没有数据,请稍等)。

    第 5 步: 您可以看到这样的请求“GET /test4.html”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-07
      • 2020-12-14
      • 1970-01-01
      • 2021-09-07
      • 2020-11-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多