Aspnetcore: Microsoft.AspNetCore.Hosting throws Startup assembly StartupBootstrapper failed to execute

Created on 28 Sep 2019  路  47Comments  路  Source: dotnet/aspnetcore

I see these errors logged on Azure (App Service) on every restart of the App Service:

Main message:

Startup assembly StartupBootstrapper failed to execute. See the inner exception for more details. Could not load file or assembly 'StartupBootstrapper, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified. 

Stack trace:

System.InvalidOperationException:
System.IO.FileNotFoundException:
   at System.Reflection.RuntimeAssembly.nLoad (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Reflection.Assembly.Load (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Reflection.Assembly.Load (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.ExecuteHostingStartups (Microsoft.AspNetCore.Hosting, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)

Let me know what additional data I can collect for you that may help in fixing this issue.

External area-hosting

Most helpful comment

Note, this is reproducible in Core 3.1.

All 47 comments

This happens when the IHostingStartup in site extensions fail to load. StartupBootstrapper is an application insights type see https://github.com/Microsoft/ApplicationInsights-Home/issues/231.

BTW is your application self contained?

@davidfowl :

I tried reading https://github.com/microsoft/ApplicationInsights-Home/issues/231 and the attached issue https://github.com/aspnet/AspNetCore/issues/5919. It is unclear what exactly resolved the issue -- and if in fact the issue was resolved in those cases.

Yes, my application is self-contained, here's the config:

Done (and desired) by me, manually:

  • Azure App Service, Windows environment, Code deployment
  • Code built on .NET Core 3.0 Preview, C# 8.0 Preview (cutting bleeding edge!) using Azure DevOps CI pipeline from a GitHub repo.
  • Application Insights installed into app via Visual Studio's Connected Services > Application Insights page. It shows "100% configured".
  • Application Insights is enabled in "full" mode (everything except SQL collection is ON) in Azure Portal.

I didn't want to go into Azure Portal and keep updating extensions there, so I haven't installed the .NET Core 3.0 Site Extension -- this is why I have it deployed in SCD mode.

Unfortunately right now, the site extensions do not work with self contained deployments. You'll need to add the Application Insights SDK manually to get it working.

I didn't want to go into Azure Portal and keep updating extensions there, so I haven't installed the .NET Core 3.0 Site Extension -- this is why I have it deployed in SCD mode.

I think you'd need to remove the site extension to prevent it from throwing at startup.

The only Site Extension present on this app service (as per App Service > Extensions blade on the portal is ASP.NET Core Logging Extensions of version 2.2.0. And, I have not installed this myself, it is something Azure does.

Could you clarify what you mean by "You'll need to add the Application Insights SDK manually" ? I have installed it from within the Visual Studio IDE.

OK I spent some time looking into this and you can't get rid of this exception today if the application is self contained. The feature being used to inject application insights into the application always fails on startup (because of a limitation in the current design).

The only way to get rid of it today is to do a framework dependent deployment by either waiting for 3.0 to be installed on app service or by using the ASP.NET Core runtime site extension.

I'll keep this issue open and assign it to myself as it's something we need to solve.

Thanks @davidfowl.

Strange thing is, the Application Insights seems to be working fine. I see the traffic, exceptions and everything else as I normally should. This means App Insights is still being loaded?

Strange thing is, the Application Insights seems to be working fine. I see the traffic, exceptions and everything else as I normally should. This means App Insights is still being loaded?

Yes, it works fine but it'll still try to load some other pieces of code at startup and always fail.

Tangential question - Is there a way to simulate how an self-contained deployment would work in a local (laptop/PC) environment?

What do you mean exactly? You can self contain publish and then run the published application locally? Is there something more you were looking for?

Let's say you need to troubleshoot a problem (like the topic of this assembly load). You'd need an environment that mimics it right? So how would you mimic an SCD environment?

When I publish and run an SCD application locally, the runtime is already present globally because of my primary .NET Core installation.

Its doesnt matter if the runtime is already present globally it won't be used. The application produced has no ties to the globally installed runtime.

I'll keep this issue open and assign it to myself as it's something we need to solve.

What's the action you want to take here @davidfowl ?

We're working with the App insights team on resolving this for 3.0.

Ok, so at the moment there is no action on our side. I'll leave this open to track that work though.

Any update or issue tracking this @davidfowl ? Can you loop me in on conversations related to this?

I'm facing the same issue after upgrading our web app from 2.1 to 3.0. However, it is not self-contained. Shall I open a new issue for that case?

I'm facing the same issue after upgrading our web app from 2.1 to 3.0. However, it is _not_ self-contained. Shall I open a new issue for that case?

This is likely part of https://github.com/aspnet/AspNetCore/issues/15381 (the issue refers to 5.0 but there's a 3.0 problem as well).

Note, this is reproducible in Core 3.1.

We're seeing this issue on Azure App Service Windows Servers + .NET Core 3.1 + FDD (not SCD as above). The same app deployed to Azure App Service Linux Containers + .NET Core 3.1 + FDD does not have this issue. There is also another immediate log entry related to Microsoft.AspNetCore.AzureAppServices.HostingStartup, copying that here too for SEO and other folks hitting this issue.

What's the timeline to resolution? It's holding up our production migration to 3.1 since it's LTS.

2019-12-12 23:31:06.885 +00:00 [Critical] Microsoft.AspNetCore.Hosting.Diagnostics:
Hosting startup assembly exception
System.InvalidOperationException: Startup assembly DiagnosticServices.HostingStartup failed to execute. See the inner exception for more details.
 ---> System.IO.FileNotFoundException: Could not load file or assembly 'DiagnosticServices.HostingStartup, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'DiagnosticServices.HostingStartup, Culture=neutral, PublicKeyToken=null'
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly assemblyContext, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.ExecuteHostingStartups()


   --- End of inner exception stack trace ---
------------------------------
2019-12-12 23:31:07.897 +00:00 [Critical] Microsoft.AspNetCore.Hosting.Diagnostics:
Hosting startup assembly exception
System.InvalidOperationException: Startup assembly Microsoft.AspNetCore.AzureAppServices.HostingStartup failed to execute. See the inner exception for more details.
 ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.AzureAppServices.HostingStartup, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'Microsoft.AspNetCore.AzureAppServices.HostingStartup, Culture=neutral, PublicKeyToken=null'
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly assemblyContext, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.ExecuteHostingStartups()


   --- End of inner exception stack trace ---

What's the timeline to resolution? It's holding up our production migration to 3.1 since it's LTS.

What's holding up anything? The application should still be working. Is that not the case?

@davidfowl To be honest, the application does bootup and we see it working fine under full load test. But we're also seeing some automatic restart every a 4-6 hours, under 0% load. This kills our <200 ms response time SLAs as cold restarts are clocking in at 45 seconds (haven't looked into ready2run optimizations yet).

Back to attribution, logging shows only the following smoking guns:

  1. App layer: this Application Insight issue (i.e. https://github.com/aspnet/AspNetCore/issues/14547) which we're seeing only on the ASP.NET Core 3.1 + Windows OS.
  2. App layer: Another Application insight issue (https://github.com/microsoft/ApplicationInsights-Profiler-AspNetCore/issues/66). This is observed on both Linux and Windows OS.
  3. Host layer: On App Service for Linux (=Linux containers) we also seeing Stoping site <sitename> because it exceeded swap usage limits. at 0% load. That results in a container recycle despite the portal's 'diagnose and solve problems' wizard showing < 500 MB use on a 3.5 GB app service plan/instance. This happens with the standard Linux container (that azure builds for us when we offer it code) as well as our custom container (but less frequently). We're still trying to figure out if this issue is rooted in one of the above two AppInsight issues.

We're not seeing any other log warn/critical/fatal messages from any other sub-system and components, hence the hesitation to go to production with azure app service (linux or windows), asp.net core 3.1 and appinsights till we can root cause and eliminate the app restarts.

@SidShetye Perhaps the best thing for you to do here would be to engage Azure Support to dig deeper in to what's going on in your specific scenario. It sounds like you're hitting the same issue, but along with some other things (since this issue should not be blocking startup of the app nor causing swap usage limits to be exceeded).

@anurse We already have an open Azure support ticket for the 3rd item.

Of course, an ApplicationInsight release that resolving these errors/warnings would be great but till then we're running some tests over the weekend to have some data supporting/rejecting the idea that these are all related stability issues.

Dropping Application Insights from the build does reduce one start up exception. But since one still emerges from Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.ExecuteHostingStartups seems beyond Application Insights and looks a lot like https://github.com/aspnet/AspNetCore/issues/14547.

This is deploying to Azure App Service Windows + .NET Core 3.1 (lets ignore the linux containers issue reported above - seems unrelated now).


Details

With Application insights

2019-12-12 23:31:06.885 +00:00 [Critical] Microsoft.AspNetCore.Hosting.Diagnostics:
Hosting startup assembly exception
System.InvalidOperationException: Startup assembly DiagnosticServices.HostingStartup failed to execute. See the inner exception for more details.
 ---> System.IO.FileNotFoundException: Could not load file or assembly 'DiagnosticServices.HostingStartup, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'DiagnosticServices.HostingStartup, Culture=neutral, PublicKeyToken=null'
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly assemblyContext, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.ExecuteHostingStartups()
   --- End of inner exception stack trace ---
------------------------------
2019-12-12 23:31:07.897 +00:00 [Critical] Microsoft.AspNetCore.Hosting.Diagnostics:
Hosting startup assembly exception
System.InvalidOperationException: Startup assembly Microsoft.AspNetCore.AzureAppServices.HostingStartup failed to execute. See the inner exception for more details.
 ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.AzureAppServices.HostingStartup, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'Microsoft.AspNetCore.AzureAppServices.HostingStartup, Culture=neutral, PublicKeyToken=null'
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly assemblyContext, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.ExecuteHostingStartups()
   --- End of inner exception stack trace --- 

Without application insights

2019-12-14 01:14:53.916 +00:00 [Critical] Microsoft.AspNetCore.Hosting.Diagnostics:
Hosting startup assembly exception
System.InvalidOperationException: Startup assembly DiagnosticServices.HostingStartup failed to execute. See the inner exception for more details.
 ---> System.IO.FileNotFoundException: Could not load file or assembly 'DiagnosticServices.HostingStartup, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'DiagnosticServices.HostingStartup, Culture=neutral, PublicKeyToken=null'
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly assemblyContext, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.ExecuteHostingStartups()
   --- End of inner exception stack trace ---

I had the same issue and exception disappeared when I uninstalled Microsoft.Extensions.Logging extension. I installed it because whenever you navigate to Monitoring -> App Service logs it shows this message "Click here to install the ASP.NET Core site extension to enable Application Logging."

What is it for if my logging works without it?

I'm getting the same error (see below) in my Azure App Service using .Net Core 3.1. Though if I create a new Angular + .Net Core 3.1 project using a VS template, and deploy that to the same App Service, it works. So I'm thinking there's a dependency that's causing this error. I have removed and disabled AppInsight from my application entirely but the error still persists.

<Event> <System> <Provider Name=".NET Runtime"/> <EventID>1025</EventID> <Level>1</Level> <Task>0</Task> <Keywords>Keywords</Keywords> <TimeCreated SystemTime="2019-12-28T00:40:07Z"/> <EventRecordID>1158170281</EventRecordID> <Channel>Application</Channel> <Computer>RD2818786EC27E</Computer> <Security/> </System> <EventData> <Data> Application: w3wp.exe CoreCLR Version: 4.700.19.56402 .NET Core Version: 3.1.0 Description: The application requested process termination through System.Environment.FailFast(string message). Message: Microsoft.AspNetCore.Hosting.Diagnostics Hosting startup assembly exception System.InvalidOperationException: Startup assembly Microsoft.AspNetCore.AzureAppServices.HostingStartup failed to execute. See the inner exception for more details. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.AzureAppServices.HostingStartup, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified. File name: 'Microsoft.AspNetCore.AzureAppServices.HostingStartup, Culture=neutral, PublicKeyToken=null' at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly assemblyContext, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, AssemblyLoadContext assemblyLoadContext) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext) at System.Reflection.Assembly.Load(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext) at System.Reflection.Assembly.Load(AssemblyName assemblyRef) at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors) --- End of inner exception stack trace --- at NLog.Targets.TraceTarget.Write(LogEventInfo logEvent) at NLog.Targets.Target.Write(AsyncLogEventInfo logEvent) at NLog.Targets.Target.WriteAsyncThreadSafe(AsyncLogEventInfo logEvent) at NLog.Targets.Target.WriteAsyncLogEvent(AsyncLogEventInfo logEvent) at NLog.LoggerImpl.WriteToTargetWithFilterChain(Target target, FilterResult result, LogEventInfo logEvent, AsyncContinuation onException) at NLog.LoggerImpl.Write(Type loggerType, TargetWithFilterChain targetsForLevel, LogEventInfo logEvent, LogFactory factory) at NLog.Logger.WriteToTargets(Type wrapperType, LogEventInfo logEvent, TargetWithFilterChain targetsForLevel) at NLog.Logger.Log(Type wrapperType, LogEventInfo logEvent) at NLog.Extensions.Logging.NLogLogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter) at Microsoft.Extensions.Logging.Logger.<Log>g__LoggerLog|12_0[TState](LogLevel logLevel, EventId eventId, ILogger logger, Exception exception, Func`3 formatter, List`1& exceptions, TState& state) at Microsoft.Extensions.Logging.Logger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter) at Microsoft.Extensions.Logging.LoggerExtensions.Log(ILogger logger, LogLevel logLevel, EventId eventId, Exception exception, String message, Object[] args) at Microsoft.Extensions.Logging.LoggerExtensions.LogCritical(ILogger logger, EventId eventId, Exception exception, String message, Object[] args) at Microsoft.AspNetCore.Hosting.HostingLoggerExtensions.ApplicationError(ILogger logger, EventId eventId, String message, Exception exception) at Microsoft.AspNetCore.Hosting.WebHost.StartAsync(CancellationToken cancellationToken) at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at Microsoft.AspNetCore.Hosting.WebHost.StartAsync(CancellationToken cancellationToken) at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage) at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage) at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token) at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token) at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host) at zoolander_ui.Program.Main(String[] args) in h:\azure-devops-agent\_work\1\s\Zoolander.UI\Program.cs:line 35 Description: The process was terminated due to an unhandled exception.System.Diagnostics.DebugProvider+DebugAssertException: Microsoft.AspNetCore.Hosting.Diagnostics Hosting startup assembly exception System.InvalidOperationException: Startup assembly Microsoft.AspNetCore.AzureAppServices.HostingStartup failed to execute. See the inner exception for more details. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.AzureAppServices.HostingStartup, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified. File name: 'Microsoft.AspNetCore.AzureAppServices.HostingStartup, Culture=neutral, PublicKeyToken=null' at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly assemblyContext, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, AssemblyLoadContext assemblyLoadContext) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext) at System.Reflection.Assembly.Load(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext) at System.Reflection.Assembly.Load(AssemblyName assemblyRef) at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors) --- End of inner exception stack trace --- at NLog.Targets.TraceTarget.Write(LogEventInfo logEvent) at NLog.Targets.Target.Write(AsyncLogEventInfo logEvent) at NLog.Targets.Target.WriteAsyncThreadSafe(AsyncLogEventInfo logEvent) at NLog.Targets.Target.WriteAsyncLogEvent(AsyncLogEventInfo logEvent) at NLog.LoggerImpl.WriteToTargetWithFilterChain(Target target, FilterResult result, LogEventInfo logEvent, AsyncContinuation onException) at NLog.LoggerImpl.Write(Type loggerType, TargetWithFilterChain targetsForLevel, LogEventInfo logEvent, LogFactory factory) at NLog.Logger.WriteToTargets(Type wrapperType, LogEventInfo logEvent, TargetWithFilterChain targetsForLevel) at NLog.Logger.Log(Type wrapperType, LogEventInfo logEvent) at NLog.Extensions.Logging.NLogLogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter) at Microsoft.Extensions.Logging.Logger.<Log>g__LoggerLog|12_0[TState](LogLevel logLevel, EventId eventId, ILogger logger, Exception exception, Func`3 formatter, List`1& exceptions, TState& state) at Microsoft.Extensions.Logging.Logger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter) at Microsoft.Extensions.Logging.LoggerExtensions.Log(ILogger logger, LogLevel logLevel, EventId eventId, Exception exception, String message, Object[] args) at Microsoft.Extensions.Logging.LoggerExtensions.LogCritical(ILogger logger, EventId eventId, Exception exception, String message, Object[] args) at Microsoft.AspNetCore.Hosting.HostingLoggerExtensions.ApplicationError(ILogger logger, EventId eventId, String message, Exception exception) at Microsoft.AspNetCore.Hosting.WebHost.StartAsync(CancellationToken cancellationToken) at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at Microsoft.AspNetCore.Hosting.WebHost.StartAsync(CancellationToken cancellationToken) at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage) at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage) at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token) at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token) at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host) at zoolander_ui.Program.Main(String[] args) in h:\azure-devops-agent\_work\1\s\Zoolander.UI\Program.cs:line 35 Stack: at System.Environment.FailFast(System.String, System.Exception, System.String) at System.Diagnostics.DebugProvider.FailCore(System.String, System.String, System.String, System.String) at System.Diagnostics.DefaultTraceListener.Fail(System.String, System.String) at System.Diagnostics.DefaultTraceListener.Fail(System.String) at System.Diagnostics.TraceInternal.Fail(System.String) at System.Diagnostics.Trace.Fail(System.String) at NLog.Targets.TraceTarget.Write(NLog.LogEventInfo) at NLog.Targets.Target.Write(NLog.Common.AsyncLogEventInfo) at NLog.Targets.Target.WriteAsyncThreadSafe(NLog.Common.AsyncLogEventInfo) at NLog.Targets.Target.WriteAsyncLogEvent(NLog.Common.AsyncLogEventInfo) at NLog.LoggerImpl.WriteToTargetWithFilterChain(NLog.Targets.Target, NLog.Filters.FilterResult, NLog.LogEventInfo, NLog.Common.AsyncContinuation) at NLog.LoggerImpl.Write(System.Type, NLog.Internal.TargetWithFilterChain, NLog.LogEventInfo, NLog.LogFactory) at NLog.Logger.WriteToTargets(System.Type, NLog.LogEventInfo, NLog.Internal.TargetWithFilterChain) at NLog.Logger.Log(System.Type, NLog.LogEventInfo) at NLog.Extensions.Logging.NLogLogger.Log[[Microsoft.Extensions.Logging.FormattedLogValues, Microsoft.Extensions.Logging.Abstractions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](Microsoft.Extensions.Logging.LogLevel, Microsoft.Extensions.Logging.EventId, Microsoft.Extensions.Logging.FormattedLogValues, System.Exception, System.Func`3<Microsoft.Extensions.Logging.FormattedLogValues,System.Exception,System.String>) at Microsoft.Extensions.Logging.Logger.<Log>g__LoggerLog|12_0[[Microsoft.Extensions.Logging.FormattedLogValues, Microsoft.Extensions.Logging.Abstractions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](Microsoft.Extensions.Logging.LogLevel, Microsoft.Extensions.Logging.EventId, Microsoft.Extensions.Logging.ILogger, System.Exception, System.Func`3<Microsoft.Extensions.Logging.FormattedLogValues,System.Exception,System.String>, System.Collections.Generic.List`1<System.Exception> ByRef, Microsoft.Extensions.Logging.FormattedLogValues ByRef) at Microsoft.Extensions.Logging.Logger.Log[[Microsoft.Extensions.Logging.FormattedLogValues, Microsoft.Extensions.Logging.Abstractions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](Microsoft.Extensions.Logging.LogLevel, Microsoft.Extensions.Logging.EventId, Microsoft.Extensions.Logging.FormattedLogValues, System.Exception, System.Func`3<Microsoft.Extensions.Logging.FormattedLogValues,System.Exception,System.String>) at Microsoft.Extensions.Logging.LoggerExtensions.Log(Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.LogLevel, Microsoft.Extensions.Logging.EventId, System.Exception, System.String, System.Object[]) at Microsoft.Extensions.Logging.LoggerExtensions.LogCritical(Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.EventId, System.Exception, System.String, System.Object[]) at Microsoft.AspNetCore.Hosting.HostingLoggerExtensions.ApplicationError(Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.EventId, System.String, System.Exception) at Microsoft.AspNetCore.Hosting.WebHost+<StartAsync>d__27.MoveNext() at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.AspNetCore.Hosting.WebHost+<StartAsync>d__27, Microsoft.AspNetCore.Hosting, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](<StartAsync>d__27 ByRef) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.AspNetCore.Hosting.WebHost+<StartAsync>d__27, Microsoft.AspNetCore.Hosting, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](<StartAsync>d__27 ByRef) at Microsoft.AspNetCore.Hosting.WebHost.StartAsync(System.Threading.CancellationToken) at Microsoft.AspNetCore.Hosting.WebHostExtensions+<RunAsync>d__5.MoveNext() at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.AspNetCore.Hosting.WebHostExtensions+<RunAsync>d__5, Microsoft.AspNetCore.Hosting, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](<RunAsync>d__5 ByRef) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.AspNetCore.Hosting.WebHostExtensions+<RunAsync>d__5, Microsoft.AspNetCore.Hosting, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](<RunAsync>d__5 ByRef) at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(Microsoft.AspNetCore.Hosting.IWebHost, System.Threading.CancellationToken, System.String) at Microsoft.AspNetCore.Hosting.WebHostExtensions+<RunAsync>d__4.MoveNext() at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.AspNetCore.Hosting.WebHostExtensions+<RunAsync>d__4, Microsoft.AspNetCore.Hosting, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](<RunAsync>d__4 ByRef) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.AspNetCore.Hosting.WebHostExtensions+<RunAsync>d__4, Microsoft.AspNetCore.Hosting, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](<RunAsync>d__4 ByRef) at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(Microsoft.AspNetCore.Hosting.IWebHost, System.Threading.CancellationToken) at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(Microsoft.AspNetCore.Hosting.IWebHost) at zoolander_ui.Program.Main(System.String[]) </Data> </EventData> </Event>

The callstack explains it pretty clearly (thanks for that):

at System.Environment.FailFast(System.String, System.Exception, System.String) 
at System.Diagnostics.DebugProvider.FailCore(System.String, System.String, System.String, System.String) 
at System.Diagnostics.DefaultTraceListener.Fail(System.String, System.String) 
at System.Diagnostics.DefaultTraceListener.Fail(System.String) 
at System.Diagnostics.TraceInternal.Fail(System.String) 
at System.Diagnostics.Trace.Fail(System.String) 
at NLog.Targets.TraceTarget.Write(NLog.LogEventInfo) 
at NLog.Targets.Target.Write(NLog.Common.AsyncLogEventInfo) 
at NLog.Targets.Target.WriteAsyncThreadSafe(NLog.Common.AsyncLogEventInfo) 
at NLog.Targets.Target.WriteAsyncLogEvent(NLog.Common.AsyncLogEventInfo) 
at NLog.LoggerImpl.WriteToTargetWithFilterChain(NLog.Targets.Target, NLog.Filters.FilterResult, NLog.LogEventInfo, NLog.Common.AsyncContinuation) 
at NLog.LoggerImpl.Write(System.Type, NLog.Internal.TargetWithFilterChain, NLog.LogEventInfo, NLog.LogFactory) 
at NLog.Logger.WriteToTargets(System.Type, NLog.LogEventInfo, NLog.Internal.TargetWithFilterChain) 
at NLog.Logger.Log(System.Type, NLog.LogEventInfo) 
at NLog.Extensions.Logging.NLogLogger.Log[[Microsoft.Extensions.Logging.FormattedLogValues, Microsoft.Extensions.Logging.Abstractions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](Microsoft.Extensions.Logging.LogLevel, Microsoft.Extensions.Logging.EventId, Microsoft.Extensions.Logging.FormattedLogValues, System.Exception, System.Func`3<Microsoft.Extensions.Logging.FormattedLogValues,System.Exception,System.String>) 
at Microsoft.Extensions.Logging.Logger.<Log>g__LoggerLog|12_0[[Microsoft.Extensions.Logging.FormattedLogValues, Microsoft.Extensions.Logging.Abstractions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](Microsoft.Extensions.Logging.LogLevel, Microsoft.Extensions.Logging.EventId, Microsoft.Extensions.Logging.ILogger, System.Exception, System.Func`3<Microsoft.Extensions.Logging.FormattedLogValues,System.Exception,System.String>, System.Collections.Generic.List`1<System.Exception> ByRef, Microsoft.Extensions.Logging.FormattedLogValues ByRef) 
at Microsoft.Extensions.Logging.Logger.Log[[Microsoft.Extensions.Logging.FormattedLogValues, Microsoft.Extensions.Logging.Abstractions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](Microsoft.Extensions.Logging.LogLevel, Microsoft.Extensions.Logging.EventId, Microsoft.Extensions.Logging.FormattedLogValues, System.Exception, System.Func`3<Microsoft.Extensions.Logging.FormattedLogValues,System.Exception,System.String>) 
at Microsoft.Extensions.Logging.LoggerExtensions.Log(Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.LogLevel, Microsoft.Extensions.Logging.EventId, System.Exception, System.String, System.Object[]) 
at Microsoft.Extensions.Logging.LoggerExtensions.LogCritical(Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.EventId, System.Exception, System.String, System.Object[]) 
at Microsoft.AspNetCore.Hosting.HostingLoggerExtensions.ApplicationError(Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.EventId, System.String, System.Exception) 
at Microsoft.AspNetCore.Hosting.WebHost+<StartAsync>d__27.MoveNext() 
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.AspNetCore.Hosting.WebHost+<StartAsync>d__27, Microsoft.AspNetCore.Hosting, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](<StartAsync>d__27 ByRef) 
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.AspNetCore.Hosting.WebHost+<StartAsync>d__27, Microsoft.AspNetCore.Hosting, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](<StartAsync>d__27 ByRef) 
at Microsoft.AspNetCore.Hosting.WebHost.StartAsync(System.Threading.CancellationToken) 
at Microsoft.AspNetCore.Hosting.WebHostExtensions+<RunAsync>d__5.MoveNext() 
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.AspNetCore.Hosting.WebHostExtensions+<RunAsync>d__5, Microsoft.AspNetCore.Hosting, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](<RunAsync>d__5 ByRef) 
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.AspNetCore.Hosting.WebHostExtensions+<RunAsync>d__5, Microsoft.AspNetCore.Hosting, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](<RunAsync>d__5 ByRef) 
at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(Microsoft.AspNetCore.Hosting.IWebHost, System.Threading.CancellationToken, System.String) 
at Microsoft.AspNetCore.Hosting.WebHostExtensions+<RunAsync>d__4.MoveNext() 
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.AspNetCore.Hosting.WebHostExtensions+<RunAsync>d__4, Microsoft.AspNetCore.Hosting, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](<RunAsync>d__4 ByRef) 
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.AspNetCore.Hosting.WebHostExtensions+<RunAsync>d__4, Microsoft.AspNetCore.Hosting, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](<RunAsync>d__4 ByRef) 
at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(Microsoft.AspNetCore.Hosting.IWebHost, System.Threading.CancellationToken) 
at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(Microsoft.AspNetCore.Hosting.IWebHost) 
at zoolander_ui.Program.Main(System.String[])

Nlog -> Trace.Fail -> Environment.FailFast

Seems like NLog ends up indirectly calling failfast for LogFatal which maps to ILogger.LogCritical.

```C#
using NLog;
using NLog.Targets;

namespace WebApplication408
{
public class Program
{
public static void Main(string[] args)
{
TraceTarget target = new TraceTarget();
NLog.Config.SimpleConfigurator.ConfigureForTargetLogging(target, NLog.LogLevel.Trace);

        Logger logger = LogManager.GetLogger("Example");
        logger.Fatal("log message");
    }
}

}

With ILogger

```C#
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using NLog;
using NLog.Targets;
using NLog.Web;

namespace WebApplication408
{
    public class Program
    {
        public static void Main(string[] args)
        {
            TraceTarget target = new TraceTarget();
            NLog.Config.SimpleConfigurator.ConfigureForTargetLogging(target, NLog.LogLevel.Trace);

            Host.CreateDefaultBuilder(args)
                .ConfigureServices(services =>
                {
                    services.AddHostedService<Service>();
                })
                .UseNLog()
                .Build()
                .Run();
        }

        public class Service : IHostedService
        {
            public Service(ILogger<Service> logger)
            {
                logger.LogCritical("This is serious!");
            }

            public Task StartAsync(CancellationToken cancellationToken)
            {
                return Task.CompletedTask;
            }

            public Task StopAsync(CancellationToken cancellationToken)
            {
                return Task.CompletedTask;
            }
        }
    }
}

cc @304NotModified any ideas?

@andliang did you explicitly configure the trace target?

@SidShetye see this thread https://github.com/aspnet/AspNetCore/issues/17370#issue-527904746

Thanks for the quick response @davidfowl. So after removing Nlog, my app works! Also, leaving Nlog installed but removing ASP.NET Core Logging Extensions works as well. Is this an issue with Nlog or NET Core Logging Extensions?
Thanks

@andliang what nlog targets do you have configured? Show me your nlog configuration.

Sure. Just a FYI, this worked with ASP.NET Core 2.2

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      autoReload="true"
      internalLogLevel="info"
      internalLogFile="d:\home\LogFiles\nlog\nlog-UI-internal.txt">

  <!-- enable asp.net core layout renderers -->
  <extensions>
    <add assembly="NLog.Web.AspNetCore"/>
  </extensions>

  <!-- the targets to write to -->
  <targets>
    <!-- write logs to file  -->


    <target xsi:type="File" name="allfile" fileName="d:\home\LogFiles\nlog\nlog-UI-all-${shortdate}.log"
            layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}" />

    <target xsi:type="File" name="debugfile" fileName="d:\home\LogFiles\nlog\nlog-UI-debug-${shortdate}.log"
            layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}" />

    <target xsi:type="File" name="errorfile" fileName="d:\home\LogFiles\nlog\nlog-UI-error-${shortdate}.log"
            layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}" />

    <!-- another file log, only own logs. Uses some ASP.NET core renderers -->
    <target xsi:type="File" name="ownFile-web" fileName="d:\home\LogFiles\nlog\nlog-UI-all-web-${shortdate}.log"
            layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action}" />

    <target xsi:type="Trace" name="trace" layout="${logger} ${message} ${exception:format=tostring}" />

  </targets>

  <!-- rules to map from logger name to target -->
  <rules>

    <!--Logs to Azure Streaming Log-->
    <logger name="*" minlevel="Trace" writeTo="trace" />

    <!--All logs, including from Microsoft-->
    <logger name="*" minlevel="Trace" writeTo="allfile" />
    <logger name="*" minlevel="Debug" writeTo="debugfile" />
    <logger name="*" minlevel="Error" writeTo="errorfile" />
    <!--Skip non-critical Microsoft logs and so log only own logs-->
    <logger name="Microsoft.*" maxLevel="Info" final="true" />
    <!-- BlackHole without writeTo -->
    <logger name="*" minlevel="Trace" writeTo="ownFile-web" />
  </rules>
</nlog>

This line:

<target xsi:type="Trace" name="trace" layout="${logger} ${message} ${exception:format=tostring}" />

Remove the "trace" target and it should work.

@davidfowl , yup that worked - thanks again. Have yourself a happy new decade!

Alternative you can enable rawWrite="true" for the Trace-Target (Skips LogLevel mapping but always uses Trace.WriteLine)

<target xsi:type="Trace" name="trace" layout="${logger} ${message} ${exception:format=tostring}" rawWrite="True" />

We were able to eliminate the error (see error below) around Microsoft.AspNetCore.AzureAppServices.HostingStartup by uninstalling the site extension ASP.NET Core Logging Integration. It's a trap because the Azure portal presents this large nag button

DO NOT CLICK THAT NAG 馃憞

image

If you accidentally click on that nag, it'll install the extension without any confirmation and the errors with return.

@davidfowl : Does this add up in your view? Is there a better recommendation for this fix?

error

2020-01-04 00:05:56.902 +00:00 [Critical] Microsoft.AspNetCore.Hosting.Diagnostics:
Hosting startup assembly exception
System.InvalidOperationException: Startup assembly Microsoft.AspNetCore.AzureAppServices.HostingStartup failed to execute. See the inner exception for more details.
 ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.AzureAppServices.HostingStartup, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'Microsoft.AspNetCore.AzureAppServices.HostingStartup, Culture=neutral, PublicKeyToken=null'
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly assemblyContext, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.ExecuteHostingStartups()

@SidShetye I said it 11 days ago but nobody seemed to notice.

Aaand we resolved the other error (see below) by once again disabling another portal-enabled extension. This time it was the Application Insights that was actually enabled on ANOTHER slot (a .net fw 4.6.1 app) of the same web app service.

image

To be honest, these portal injected 'magic' extensions have rather painful in our experience. They don't feel production-ready (all the tickets), hurt testability (behavior changes post-testing), aren't well documented (like which env variables are injected from which extension? cleanup?).

error

2020-01-04 18:50:51.436 +00:00 [Critical] Microsoft.AspNetCore.Hosting.Diagnostics:
Hosting startup assembly exception
System.InvalidOperationException: Startup assembly DiagnosticServices.HostingStartup failed to execute. See the inner exception for more details.
 ---> System.IO.FileNotFoundException: Could not load file or assembly 'DiagnosticServices.HostingStartup, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

Yea these are known problems. They need to be updated each version of .NET Core and there鈥檚 some lag time on the various teams. We鈥檙e looking at ways to remove this overhead going forward

I have fixed the

"Startup assembly StartupBootstrapper failed to execute. See the inner exception for more details. Could not load file or assembly 'StartupBootstrapper, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified. "

by uninstalling the Azure web app AI site extension as suggested here.

I have also fixed the

"Startup assembly Microsoft.AspNetCore.AzureAppServices.HostingStartup failed to execute. See the inner exception for more details. Could not load file or assembly 'Microsoft.AspNetCore.AzureAppServices.HostingStartup, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified. "

by installing "<PackageReference Include="Microsoft.AspNetCore.AzureAppServices.HostingStartup" Version="3.1.0" />"

Also applied the advice from https://github.com/dotnet/aspnetcore/issues/15381#issuecomment-566777363 but not sure if it helped.

Now the only issue i get is

"Startup assembly DiagnosticServices.HostingStartup failed to execute. See the inner exception for more details. Could not load file or assembly 'DiagnosticServices.HostingStartup, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified. "

which i can only fix by following the advice from https://github.com/dotnet/aspnetcore/issues/17370#issuecomment-567543883 which disables the profile and snapshot feature.

Is it possible to have profile and snapshot features working without getting the " DiagnosticServices.HostingStartup failed to execute" exception message?

I'm using framework dependant deployment from within visual studio publish screen and the app is .net core 3.1.0 64bit

Just to confirm, the steps outlined by @flatproject worked - Thanks!
Had to go through them all on a vanilla .net core 3.1.1, VS 2019 Publish, FDD.

Before arriving here, had to fix another issue in 3.1.1 with Microsoft.AspNetCore.Authentication.AzureAD.UI which was also crashing the app
https://github.com/dotnet/aspnetcore/issues/18401

All in all, 5 or 6 issues to resolve to get to a working 3.1 app through VS publish.

For this issue, specifically, I agree with the sentiment to reevaluate how these extensions affect the core service. At the minimum, if something goes wrong, they should not crash the entire app.

... which disables the profile and snapshot feature.

@flatproject On a related note, if you're on Linux, it's probably a good idea to disable Application Insights' profiling and snapshot because we're seeing an unrecoverable memory leak from it. See https://github.com/microsoft/ApplicationInsights-dotnet/issues/1678

@davidfowl Is the purpose of Microsoft.AspNetCore.AzureAppServices.HostingStartup documented anywhere? And why does AppService throw a critical log message over it?

Seems like bad practice to include an entire binary (Microsoft.AspNetCore.AzureAppServices.HostingStartup) simply to mask a log warning when we need no functionality from it.

@SidShetye The site extension enables the logging options in the azure portal for azure app service to work. The HostingStartup is a way to plug into the application startup process without that code having be in the application initially. Think of it as a plugin. There's a plugin that runs on app service to enable app service features. When it breaks it's because there's a version mismatch, that is, there's a newer version of .NET Core than the extension supports (this is what we're working on moving forward, extensions are tied to the .NET Core major minor version).

You can enable the same feature by adding the package reference directly and calling the registration API (this is what the plugin package does) and why things work if you reference the package directly.

To be honest, these portal injected 'magic' extensions have rather painful in our experience. They don't feel production-ready (all the tickets), hurt testability (behavior changes post-testing), aren't well documented (like which env variables are injected from which extension? cleanup?).

+1

Azure app services adds many maybe well intented but overall counter productive things in the portal.

Was this page helpful?
0 / 5 - 0 ratings