Reputation: 15286
All of a sudden my Azure App Service can't start a aspnetcore2.0 and there is no logs. Just error 500 and no logs in Application Insights or Streaming Servicecs in Kudu.
App works perfectly on localhost, but standalone and with IIS Express and was working fine before in Azure yesterday.
How can I troubleshoot this?
Upvotes: 1
Views: 714
Reputation: 15286
TL;DR; Azure is probably having issues with binding redirects due to other runtimes and .NET versions. Add this to your csproj in the calling code (usually your web project).
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
Troubleshooting steps:
Enable startup logging
public static IWebHost BuildWebHost(string[] args) => WebHost
.CreateDefaultBuilder(args)
.CaptureStartupErrors(true)
[...]
Open Kudu tools and watch the streaming log service
https://.scm.azurewebsites.net/api/logstream
where you might find an error like:
2017-12-09 11:53:33.304 +00:00 [Error] Microsoft.AspNetCore.Server.Kestrel: Connection id "0HL9UVDQACN2F", Request id "0HL9UVDQACN2F:00000002": An unhandled exception was thrown by the application.
System.IO.FileNotFoundException: Could not load file or assembly 'System.Net.Http.WebRequest, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Net.Http.WebRequest, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at Microsoft.Rest.ServiceClient`1.CreateRootHandler()
[..]
Look for places where your code might load an assembly, I found out that:
File name: 'System.Net.Http.WebRequest, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at Microsoft.Rest.ServiceClient`1.CreateRootHandler()
at MyApp.MiddleLayer.Services.AzureSearch.DependencyInjection.<>c.<AddAzureSearch>b__0_1(IServiceProvider x) in C:\<Path>.Services.AzureSearch\DependencyInjection.cs:line 27
Which is where I add my Azure Search code in my app.
AutoGenerateBindingRedirects
as described in top of this post.Upvotes: 3