本文介绍了App Insights升级到2.5后,Azure App Services将无法启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储库,它使用应用程序见解来记录有关在asp.net中运行的服务的信息.我们有一些ASP.NET Core 2.0站点以及一些完整的框架asp.net 4应用程序.随着应用程序见解2.5的发布,我们获得了核心站点中实时流的支持,因此我将解决方案中的所有软件包升级为使用最新的2.5.然后,我建立了分支,并通过VSTS的构建和发布对其进行了部署,我注意到我的实时流媒体工作得很好.然后,我使用较旧的2.4软件包发布了以前的版本.现在,该环境已损坏,所有核心站点都无法启动,并且出现此错误.

I have a repository that uses application insights to log information about our services running in asp.net. We have some ASP.NET Core 2.0 sites along with some full framework asp.net 4 applications. With the release of application insights 2.5, we get support for live streaming in core sites so I upgraded all packages in the solution to use latest 2.5. Then I built the branch and deployed it via VSTS build and release and I noticed my live streaming was working great. Then, I released the previous build with the older 2.4 packages. Now, that environment is broken and none of the core sites will start anymore and I get this error.

An error occurred while starting the application.

.NET Core 4.6.26020.03 X86 v4.0.0.0    |   Microsoft.AspNetCore.Hosting version 2.0.0-rtm-26452    |    Microsoft Windows 10.0.14393    |   Need help?

在应用程序日志中,我看到

In the application logs, I'm seeing

[Critical] Microsoft.AspNetCore.Hosting.Internal.WebHost: Application startup exception
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AI.ServerTelemetryChannel, Version=2.5.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.

[Critical] Microsoft.AspNetCore.Hosting.Internal.WebHost: Hosting startup assembly exception
System.InvalidOperationException: Startup assembly Microsoft.AspNetCore.AzureKeyVault.HostingStartup failed to execute. See the inner exception for more details. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.AzureKeyVault.HostingStartup, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

这是完整的错误响应:

2018-03-05 18:34:13.783 +00:00 [Critical] Microsoft.AspNetCore.Hosting.Internal.WebHost: Application startup exception
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AI.ServerTelemetryChannel, Version=2.5.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
File name: 'Microsoft.AI.ServerTelemetryChannel, Version=2.5.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
   at Microsoft.Extensions.DependencyInjection.TelemetryConfigurationOptionsSetup.AddTelemetryChannelAndProcessors(TelemetryConfiguration configuration)
   at Microsoft.Extensions.DependencyInjection.TelemetryConfigurationOptionsSetup.Configure(TelemetryConfiguration configuration)
   at Microsoft.Extensions.DependencyInjection.TelemetryConfigurationOptions..ctor(IEnumerable`1 configureOptions)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite singletonCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass22_0.<RealizeService>b__0(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ApplicationInsightsExtensions.<>c.<AddApplicationInsightsTelemetry>b__13_1(IServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite singletonCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite singletonCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite singletonCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitIEnumerable(IEnumerableCallSite enumerableCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite singletonCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass22_0.<RealizeService>b__0(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
   at Microsoft.ApplicationInsights.AspNetCore.ApplicationInsightsStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.Server.IISIntegration.IISSetupFilter.<>c__DisplayClass3_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()


2018-03-05 18:34:13.902 +00:00 [Debug] Microsoft.AspNetCore.Hosting.Internal.WebHost: Hosting starting
2018-03-05 18:34:14.273 +00:00 [Debug] Microsoft.AspNetCore.Server.Kestrel: Connection id "0HLC2OUP34I4I" started.
2018-03-05 18:34:14.354 +00:00 [Debug] Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv: Connection id "0HLC2OUP34I4I" received FIN.
2018-03-05 18:34:14.354 +00:00 [Debug] Microsoft.AspNetCore.Server.Kestrel: Connection id "0HLC2OUP34I4I" disconnecting.
2018-03-05 18:34:14.355 +00:00 [Debug] Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv: Connection id "0HLC2OUP34I4I" sending FIN.
2018-03-05 18:34:14.519 +00:00 [Debug] Microsoft.AspNetCore.Server.Kestrel: Connection id "0HLC2OUP34I4I" stopped.
2018-03-05 18:34:14.521 +00:00 [Debug] Microsoft.AspNetCore.Hosting.Internal.WebHost: Hosting started
2018-03-05 18:34:14.521 +00:00 [Debug] Microsoft.AspNetCore.Hosting.Internal.WebHost: Loaded hosting startup assembly **redacted**
2018-03-05 18:34:14.521 +00:00 [Debug] Microsoft.AspNetCore.Hosting.Internal.WebHost: Loaded hosting startup assembly Microsoft.AspNetCore.AzureAppServices.HostingStartup
2018-03-05 18:34:14.521 +00:00 [Debug] Microsoft.AspNetCore.Hosting.Internal.WebHost: Loaded hosting startup assembly Microsoft.AspNetCore.AzureKeyVault.HostingStartup
2018-03-05 18:34:14.521 +00:00 [Debug] Microsoft.AspNetCore.Hosting.Internal.WebHost: Loaded hosting startup assembly Microsoft.AspNetCore.Server.IISIntegration
2018-03-05 18:34:14.547 +00:00 [Critical] Microsoft.AspNetCore.Hosting.Internal.WebHost: Hosting startup assembly exception
System.InvalidOperationException: Startup assembly Microsoft.AspNetCore.AzureKeyVault.HostingStartup failed to execute. See the inner exception for more details. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.AzureKeyVault.HostingStartup, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks, IntPtr ptrLoadContextBinder)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, IntPtr ptrLoadContextBinder)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
   --- End of inner exception stack trace ---
2018-03-05 18:34:14.699 +00:00 [Debug] Microsoft.AspNetCore.Server.Kestrel: Connection id "0HLC2OUP34I4J" started.
2018-03-05 18:34:15.295 +00:00 [Information] Microsoft.AspNetCore.Hosting.Internal.WebHost: Request starting HTTP/1.1 GET http://localhost/
2018-03-05 18:34:15.325 +00:00 [Debug] Microsoft.AspNetCore.Server.Kestrel: Connection id "0HLC2OUP34I4J" completed keep alive response.
2018-03-05 18:34:15.326 +00:00 [Information] Microsoft.AspNetCore.Hosting.Internal.WebHost: Request finished in 30.3157ms 500 text/html; charset=utf-8
2018-03-05 18:34:15.353 +00:00 [Debug] Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv: Connection id "0HLC2OUP34I4J" reset.
2018-03-05 18:34:15.353 +00:00 [Debug] Microsoft.AspNetCore.Server.Kestrel: Connection id "0HLC2OUP34I4J" disconnecting.
2018-03-05 18:34:15.358 +00:00 [Debug] Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv: Connection id "0HLC2OUP34I4J" sending FIN.
2018-03-05 18:34:15.370 +00:00 [Debug] Microsoft.AspNetCore.Server.Kestrel: Connection id "0HLC2OUP34I4K" started.
2018-03-05 18:34:15.372 +00:00 [Debug] Microsoft.AspNetCore.Server.Kestrel: Connection id "0HLC2OUP34I4L" started.
2018-03-05 18:34:15.372 +00:00 [Debug] Microsoft.AspNetCore.Server.Kestrel: Connection id "0HLC2OUP34I4J" stopped.
2018-03-05 18:34:15.381 +00:00 [Information] Microsoft.AspNetCore.Hosting.Internal.WebHost: Request starting HTTP/1.1 GET http://***.azurewebsites.net/
2018-03-05 18:34:15.382 +00:00 [Debug] Microsoft.AspNetCore.Server.Kestrel: Connection id "0HLC2OUP34I4L" completed keep alive response.
2018-03-05 18:34:15.382 +00:00 [Information] Microsoft.AspNetCore.Hosting.Internal.WebHost: Request finished in 1.5282ms 500 text/html; charset=utf-8
2018-03-05 18:34:15.382 +00:00 [Information] Microsoft.AspNetCore.Hosting.Internal.WebHost: Request starting HTTP/1.1 GET http://***.***.com/api/health/all
2018-03-05 18:34:15.383 +00:00 [Debug] Microsoft.AspNetCore.Server.Kestrel: Connection id "0HLC2OUP34I4K" completed keep alive response.
2018-03-05 18:34:15.383 +00:00 [Information] Microsoft.AspNetCore.Hosting.Internal.WebHost: Request finished in 0.7699ms 500 text/html; charset=utf-8
2018-03-05 18:34:15.469 +00:00 [Debug] Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv: Connection id "0HLC2OUP34I4L" reset.
2018-03-05 18:34:15.469 +00:00 [Debug] Microsoft.AspNetCore.Server.Kestrel: Connection id "0HLC2OUP34I4L" disconnecting.
2018-03-05 18:34:15.469 +00:00 [Debug] Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv: Connection id "0HLC2OUP34I4L" sending FIN.
2018-03-05 18:34:15.470 +00:00 [Debug] Microsoft.AspNetCore.Server.Kestrel: Connection id "0HLC2OUP34I4L" stopped.

推荐答案

尝试执行此操作(请注意,这是usint .NET CLI,您可以在powershell或程序包管理器中使用等效项.)

Try doing this (note this is usint .NET CLI you can use equivalent in powershell or package manager).

dotnet add package Microsoft.AspNetCore.AzureKeyVault.HostingStartup --version 2.1.0-preview1-27946 --source https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json

由于某些原因,即使您不使用azure,也要引用此软件包.我发现包括AppInsights在内,它还阻止了其他许多服务的启动.

For some reason azure is referencing this package, even if you not using it.It also prevents number of other services from launching as i found out including AppInsights.

这将创建一个肮脏的项目,因为它是针对核心2.1而非核心2.0(不存在)设计的.但是它应该可以正常工作(至少在我的两个项目中都如此).

This will create a dirty project as it is designed for core 2.1 not core 2.0 (doesn't exist in it).But it should work without any issues (at least it did for 2 of my projects).

这篇关于App Insights升级到2.5后,Azure App Services将无法启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 12:00