问题
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.
and
[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.
Here's the full error response:
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.
回答1:
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
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.
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).
来源:https://stackoverflow.com/questions/49120919/azure-app-services-will-not-start-after-app-insights-upgrade-to-2-5