Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET CORE 3.1 on Azure Web Sites: 500.37 ANCM Failed to Start Within Startup Time Limit

I have .NET Core 3.1 API which is deployed in Azure web application service. I had trouble running the application in Azure because of the error 500.37 ANCM Failed to Start Within Startup Time Limit. I managed to solve this issue by increasing startupTimeLimit in web.config (as you can see below).

But Now, when I'm running 2 instances in Azure web app service. One of the instances works just fine but the other one still has the same error.

Any ideas on how How to set startupTimeLimit for multiple instances in IIS?

web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <!-- To customize the asp.net core module uncomment and edit the following section. 
  For more info see https://go.microsoft.com/fwlink/?linkid=838655 -->
  <system.webServer>
    <httpProtocol>
      <customHeaders>
        <remove name="X-Powered-By" />
      </customHeaders>
    </httpProtocol>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="dotnet" arguments=".\Clients.Api.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" startupTimeLimit="180" hostingModel="inprocess" >
    </aspNetCore>
  </system.webServer>
</configuration>

Edit:

I used azure web app Scale out (App Service plan) to increase the running instance to 2.

like image 550
Melchia Avatar asked Mar 25 '20 11:03

Melchia


People also ask

What is ANCM failed to start?

ANCM failed to start within the provided startup time limit. By default, the timeout is 120 seconds. This error can occur when starting a large number of apps on the same machine. Check for CPU/Memory usage spikes on the server during startup.

How do I troubleshoot Azure App Service?

To access App Service diagnostics, navigate to your App Service web app or App Service Environment in the Azure portal. In the left navigation, click on Diagnose and solve problems.

Do Azure Web Apps use IIS?

Additional resources. Azure App Service on Windows Server uses Internet Information Services (IIS).

What is the default Startup timeout for ancm?

By default, the timeout is 120 seconds. This error can occur when starting a large number of apps on the same machine. Check for CPU/Memory usage spikes on the server during startup. You may need to stagger the startup process of multiple apps. ANCM failed to locate the application DLL, which should be next to the executable.

Why does the ASP NET Core Module fail to start?

The ASP.NET Core Module attempts to start the .NET Core runtime in-process, but it fails to start. The most common cause of this startup failure is when the Microsoft.NETCore.App or Microsoft.AspNetCore.App runtime isn't installed. If the app is deployed to target ASP.NET Core 3.0 and that version doesn't exist on the machine, this error occurs.

Why did ancm 50031 fail to find native dependencies?

500.31 ANCM Failed to Find Native Dependencies. The worker process fails. The app doesn't start. The ASP.NET Core Module attempts to start the .NET Core runtime in-process, but it fails to start. The most common cause of this startup failure is when the Microsoft.NETCore.App or Microsoft.AspNetCore.App runtime isn't installed.

What is the default startuptimelimit of the ASP NET Core Module?

The ASP.NET Core Module is configured with a default startupTimeLimit of 120 seconds. When left at the default value, an app may take up to two minutes to start before the module logs a process failure.


2 Answers

We solved this solution by increasing the startupTimeLimit to 300

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <location>
    <system.webServer>
      <aspNetCore xdt:Transform="SetAttributes(startupTimeLimit)" startupTimeLimit="300">
      </aspNetCore>
    </system.webServer>
  </location>
</configuration>
like image 68
Melchia Avatar answered Sep 24 '22 22:09

Melchia


Finally I was able to fix this error.

It is a configuration error (.net core configuration). Azure App Services need an additional configuration of the project when it is in .net core 3.1. The solution is:

  • In project file (asp.net or web api project) (*.proj) you have to place the following line just below TargetFramework:

<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>

Final *.proj file would be something like this :

<Project Sdk="Microsoft.NET.Sdk.Web">  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>        
    <AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
    <UserSecretsId>my-secrets-go-here</UserSecretsId>
    <Version>1.1.0.0</Version>
    <Authors>me</Authors>
    <Company>TheCompany</Company>
    <Platforms>AnyCPU;x64</Platforms>
  </PropertyGroup>
  ...
</Project>

And that's it. After adding those changes and uploading a new version on your Azure App Service the application is going to be executed without errors (unless there's something else related to your code).

I was able to replicate this error by executing my project directly on IIS from my local, when you do that VS opens the web browser but the web page is never loaded.

like image 35
Diego Arturo Barriguete Avatar answered Sep 23 '22 22:09

Diego Arturo Barriguete