应用程序洞察异常和失败

时间:2015-09-29 22:02:45

标签: c# asp.net azure visual-studio-2015 azure-application-insights

我尝试在Azure预览门户和Visual Studio 2015社区版中使用Application Insights。我遇到了三个不同的问题,我怀疑这些问题都是相关的。我想知道其他人是否遇到这些问题。

在我的一个测试Web应用程序中,App-Insight工具部分正常工作。在另一个我收到有关无法挽回数据的错误。第三,当我将App-Insight与新资源组中的资源一起使用时,我遇到了部署失败。

我将在这个问题中提出这三个问题,因为我怀疑它们可能都有相同的根本原因。

部分结果

我尝试使用app-insight进行改造的第一个应用程序实际上可以工作并显示应用程序洞察遥测......或者至少它主要起作用。遥测数据的一半显示,其余的没有。

telemetry

设置的顺序如下:

我从2015年6月开始安装sample Mobile-MVC app that came with this MSDN Magazine article。在摆弄添加引导程序以制作响应式页面之后,我决定将代码提交到VS在线GIT,然后部署为Azure Web应用程序。< / p>

然后我按照View logs in Application Insights的说明运行了应用程序,该应用程序成功启动了浏览器并允许我与该站点进行交互。但是,在本练习中,我在Visual Studio输出窗口中显示了大量异常。我在这里加了一个小片段,在那里我加了最有趣的两件作品:

  

抛出异常:&#39; System.MethodAccessException&#39;在Microsoft.ApplicationInsights.Extensibility.DependencyCollector.dll中   抛出异常:&#39; System.TypeInitializationException&#39;在Microsoft.ApplicationInsights.Extensibility.DependencyCollector.dll中   抛出异常:&#39; System.TypeInitializationException&#39;在Microsoft.ApplicationInsights.Extensibility.DependencyCollector.dll中    ApplicationInsightsHttpModule在初始化时因异常而失败:System.TypeInitializationException:&#39; Microsoft.ApplicationInsights.Extensibility.DependencyCollector.Tracing.DependencyCollectorEventSource&#39;的类型初始值设定项。抛出一个例外。 ---&GT; System.MethodAccessException:尝试方法&#39; Microsoft.ApplicationInsights.Extensibility.DependencyCollector.Tracing.DependencyCollectorEventSource..ctor()&#39;访问方法&#39; Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.ApplicationNameProvider..ctor()&#39;失败。
     在Microsoft.ApplicationInsights.Extensibility.DependencyCollector.Tracing.DependencyCollectorEventSource..ctor()      在Microsoft.ApplicationInsights.Extensibility.DependencyCollector.Tracing.DependencyCollectorEventSource..cctor()      ---内部异常堆栈跟踪结束---      at Microsoft.ApplicationInsights.Extensibility.DependencyCollector.DependencyTrackingTelemetryModule.Initialize(TelemetryConfiguration configuration)      在Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationFactory.InitializeComponents(IEnumerable components,TelemetryConfiguration configuration)      at Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationFactory.InitializeComponents(TelemetryConfiguration configuration)      在Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationFactory.Initialize(TelemetryConfiguration配置)      在Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.get_Active()      在Microsoft.ApplicationInsights.Extensibility.Web.ApplicationInsightsHttpModule..ctor()

     

[msg = Log Error]; [msg = System.TypeLoadException:无法加载类型&#39; Microsoft.ApplicationInsights.Channel.JsonSerializer&#39;来自assembly&#39; Microsoft.ApplicationInsights,Version = 1.2.0.5639,Culture = neutral,PublicKeyToken = 31bf3856ad364e35&#39;。      在Microsoft.ApplicationInsights.Extensibility.Web.Implementation.TelemetrySerializer.d__0.MoveNext()      在System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start [TStateMachine](TStateMachine&amp; stateMachine)      在Microsoft.ApplicationInsights.Extensibility.Web.Implementation.TelemetrySerializer.SerializeAsync(IEnumerable 1 items) at Microsoft.ApplicationInsights.Extensibility.Web.Implementation.TelemetryBuffer.<>c__DisplayClass5.<FlushAsync>b__3() at System.Threading.Tasks.Task 1.InnerInvoke()      在System.Threading.Tasks.Task.Execute()   ---从抛出异常的先前位置开始的堆栈跟踪结束---      在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)      在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)      在Microsoft.ApplicationInsights.Extensibility.Web.Implementation.TelemetryBuffer.d__7.MoveNext()   ---从抛出异常的先前位置开始的堆栈跟踪结束---      在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)      在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)      在Microsoft.ApplicationInsights.Extensibility.Implementation.TaskTimer。&lt;&gt; c__DisplayClass1。&lt; b__0&gt; d__3.MoveNext()]

我的Azure门户正在接收某些东西的遥测,但没有其他东西。简而言之,如上述例外情况所示,产生遥测的能力已经瘫痪。

现在是下一个问题。

新资源组

使用预览门户,我创建了一个名为&#34; SandBox&#34;的全新资源组。再次使用预览门户,我创建了一个全新的Web应用程序,名为&#34; ScratchWeb&#34;我分配给&#34; Sandbox&#34;资源组。

Web资源的部署最终完成,但是有一个关联的应用程序洞察资源称为&#34;&#34; Microsoft.WebSite3cb98c31-893c&#34;&#34;自动创建,在最终被声明为失败的部署之前会经历十几个超时错误。下面我展示了一个超时错误的示例,以及提供一些关键信息的最终错误。

Operation Id
1E2094CECE6531F1
Tracking Id
31283062-9061-4dcf-bd42-f9885abbf596
Status
GatewayTimeout
Provisioning State
Running
Timestamp
‎9‎/‎28‎/‎2015‎ ‎10‎:‎37‎:‎59‎ ‎PM
Duration
PT30.7117477S
Type
microsoft.insights/components
Resource Id
/subscriptions/da769a1f-78d8-4d45-b9b3-c15ea0c89ca2/resourceGroups/SandBox/providers/microsoft.insights/components/ScratchWeb
StatusMessage
{"code":"GatewayTimeout","message":"Request timed out","innererror":{"diagnosticcontext":"034b642f-aece-494b-9ede-f8b015f5bfeb","time":"2015-09-29T05:37:59.8355234Z","data":"d0fe44bb-8317-4359-bf2c-160f1eb00433"}}
Resource
ScratchWeb

这是最终失败错误消息:

Operation Id
1E2094CECE6531F1
Tracking Id
08dbbf0a-0d4a-4692-9b1a-3603a984d40d
Status
Conflict
Provisioning State
Failed
Timestamp
‎9‎/‎28‎/‎2015‎ ‎10‎:‎48‎:‎16‎ ‎PM
Duration
PT10M47.5300298S
Type
microsoft.insights/components
Resource Id
/subscriptions/da769a1f-78d8-4d45-b9b3-c15ea0c89ca2/resourceGroups/SandBox/providers/microsoft.insights/components/ScratchWeb
StatusMessage
{"code":"The component already existed in a different resource group.","message":"The component already existed in a different resource group.","innererror":{"diagnosticcontext":"9ea42d3d-4dbf-46e8-a188-eac09a4ddb09","time":"2015-09-29T05:48:15.7282268Z"}}
Resource
ScratchWeb

这是因为&#34; Application Insights&#34;预览不能在多个资源组中运行,或者是因为我的订阅不允许它?

最奇怪的是,一旦app-insights资源的部署最终失败,它似乎已经创建,并且在我的Application Insights资源集合中不可见。

现在最后一个问题......

原始资源组

如果我尝试在现有中创建新网站,默认网络应用资源组...则不会出现上述任何问题。不幸的是我遇到了另一个问&#34;应用洞察力&#34;资源刀片告诉我&#34;错误检索数据&#34;当它试图向我展示图表时。另一方面,Visual Studio告诉我一切都很好......它说的是#34;恭喜,你已经发布了第一个应用洞察数据。&#34;

no data no data

因此,最后,我只有一个Web应用程序具有可查看的App-Insight结果,并且这些结果已经瘫痪。无论我是使用现有资源组还是尝试使用新资源组,我尝试使用app-insight创建第二个有效的Web应用程序都是不成功的。

使用Visual Studio 2015,我使用了两种不同的方法来尝试添加App-Insight SDK。事后我尝试将它添加到我的web项目中,我也尝试从新的项目模板中添加它。我任何工作的唯一情况是我在第一个网络应用程序上进行了检测&#34;事后&#34;使用App-Insight SDK。不幸的是(1)这些结果已经瘫痪了,(2)正如我上面所描述的那样,我甚至无法实现瘫痪的&#34;结果第二次。因此,现在App-Insight功能对我来说是行不通的。

1 个答案:

答案 0 :(得分:5)

尝试删除对Application Insights的所有引用,清理项目。然后添加NuGet包Microsoft.ApplicationInsights.Web,目前版本为1.2.1。

PM> Install-Package Microsoft.ApplicationInsights.Web

这将安装所有必需的依赖项。安装完成后,在订阅中创建Application Insights资源(按照Add Application Insights SDK to monitor your ASP.NET app中的说明操作),并将Instrumentation键添加到您的应用中。我建议将检测密钥放在web.config设置中:

  <appSettings>
    <add key="AppInsightsInstrumentationKey" value="your-key-value" />
  </appSettings>

并将其添加到Application_Start中的应用程序中,如:

TelemetryConfiguration.Active.InstrumentationKey = ConfigurationManager.AppSettings["AppInsightsInstrumentationKey"] ?? "some-default-key";

更新 ---

还有更多疑难解答信息here

  • 如果未记录浏览器事件:
    • 如果您的浏览器客户端前面有防火墙,则可能需要打开TCP端口80和443以获取到dc.services.visualstudio.com和f5.services.visualstudio.com的传出流量。
    • 在浏览器开发者工具中,查找&#34; track&#34;网络标签上的条目 - 应该将数据发布到https://dc.services.visualstudio.com/v2/track(或fc ...)
  • 如果服务器数据未录制:
    • 通过Azure Portal安装应用洞察:浏览到您的WebApp&gt;&gt;工具&gt;&gt;扩展,然后安装Application Insights扩展。