Azure WebApp Asp.NET Core 2 error: An error occurred while starting the application
Please add ASPNETCORE_DETAILEDERRORS = true
in app settings of your app, restart it and see the detailed error next time you load the url.
That will help you fix it.
For example, error in my case was that I didn't have the managed identity of my API App configured to access the Key Vault to get the storage account and Cosmos DB keys. I used startup to inject the configured storage and cosmos db objects hence it was failing the moment I was starting my app.
When you've fixed the startup issue, don't forget to remove this setting as leaving it on could expose information about how the application works to visitors in the event of another error.
Got my tips from https://scottsauber.com/2017/04/10/how-to-troubleshoot-an-error-occurred-while-starting-the-application-in-asp-net-core-on-iis/
- Open your web.config
- Change stdoutLogEnabled=true
- Create a logs folder Unfortunately, the AspNetCoreModule doesn’t create the folder for you by default If you forget to create the logs folder, an error will be logged to the Event Viewer that says: Warning: Could not create stdoutLogFile \?\YourPath\logs\stdout_timestamp.log, ErrorCode = -2147024893. The “stdout” part of the value “.\logs\stdout” actually references the filename not the folder. Which is a bit confusing. Run your request again, then open the \logs\stdout_*.log file
Note – you will want to turn this off after you’re done troubleshooting, as it is a performance hit.
So your web.config’s aspNetCore element should look something like this
<aspNetCore processPath=”.\YourProjectName.exe” stdoutLogEnabled=”true” stdoutLogFile=”.\logs\stdout” />
Enable DetailedErrorsKey
in the Program.cs
so you can figure it out what's happening.
WebHost.CreateDefaultBuilder(args)
.UseSetting(WebHostDefaults.DetailedErrorsKey, "true")