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

11,402

Solution 1

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>

Solution 2

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.

Share:
11,402
Melchia
Author by

Melchia

Full Stack developer. Technologies: Javascript, Typescript, C#, Python Angular, React, NextJS NodeJs, .Net core Rest, GraphQL MongoDB, PostgreSQL Azure Devops, Github actions, Jenkins. Docker

Updated on June 27, 2022

Comments

  • Melchia
    Melchia almost 2 years

    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.

  • TheBeast
    TheBeast over 2 years
    Thanks. Ran into this after updating an old legacy .net 1.1 app to 3.1
  • Diego Arturo Barriguete
    Diego Arturo Barriguete over 2 years
    My pleasure, it's a tricky bug.
  • tobbenb3
    tobbenb3 about 2 years
    This allowed me to figure out how to fix the issue. weblog.west-wind.com/posts/2020/Jan/14/…