【问题标题】:.NET CORE 3.1 on Azure Web Sites: 500.37 ANCM Failed to Start Within Startup Time LimitAzure 网站上的 .NET CORE 3.1:500.37 ANCM 无法在启动时间限制内启动
【发布时间】:2020-03-25 11:06:33
【问题描述】:

我有部署在 Azure Web 应用程序服务中的 .NET Core 3.1 API。由于错误 500.37 ANCM Failed to Start Within Startup Time Limit,我在 Azure 中运行应用程序时遇到了问题。我设法通过增加 web.config 中的 startupTimeLimit 来解决这个问题(如下所示)。

但是现在,当我在 Azure Web 应用服务中运行 2 个实例时。其中一个实例运行良好,但另一个实例仍然存在相同的错误。

关于如何在 IIS 中为多个实例设置 startupTimeLimit 的任何想法?

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>

编辑:

我使用 azure web app Scale out (App Service plan) 将运行实例增加到 2。

【问题讨论】:

  • Azure 中有什么服务?虚拟机还是应用服务?
  • @LexLi Azure 应用服务使用 Azure 资源管理器。
  • 你的意思是你使用azure web app scale out来增加运行实例?据我所知,每个实例都将使用相同的 web,config 文件。
  • @BrandoZhang 是的。我编辑了我的帖子
  • 正如我所说,两个 azure Web 应用程序实例都将使用相同的 web.config。我猜这个问题也和startupTimeLimit的值有关,第二个instance比instance1耗时,建议你可以尝试增加startupTimeLimit再试一次。

标签: azure asp.net-core iis .net-core azure-web-app-service


【解决方案1】:

我们通过将 startupTimeLimit 增加到 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>

【讨论】:

    【解决方案2】:

    我终于能够修复这个错误。

    这是一个配置错误(.net 核心配置)。 Azure App Services 在 .net core 3.1 中时需要对项目进行额外配置。 解决办法是:

    • 在项目文件(asp.net 或 web api 项目)(*.proj) 中,您必须在 TargetFramework 正下方放置以下行:

    &lt;AspNetCoreHostingModel&gt;OutOfProcess&lt;/AspNetCoreHostingModel&gt;

    最终的 *.proj 文件是这样的:

    <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>
    

    就是这样。添加这些更改并在您的 Azure 应用服务上上传新版本后,应用程序将在没有错误的情况下执行(除非有与您的代码相关的其他内容)。

    我可以通过从本地直接在 IIS 上执行我的项目来复制此错误,当您这样做时,VS 会打开 Web 浏览器但从未加载过网页。

    【讨论】:

    • 谢谢。在将旧的 .net 1.1 应用程序更新到 3.1 后遇到了这个问题
    • 我很高兴,这是一个棘手的错误。
    • 这让我知道如何解决这个问题。 weblog.west-wind.com/posts/2020/Jan/14/…
    【解决方案3】:

    Melchia,我遇到了同样的问题,我尝试了您的解决方案,但是当我在 web.config 中应用它时,我收到 500 服务器错误。

    我必须使用其他设置,以便我的 web.config 是:

    <?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>
        <system.webServer>
            <security>
                <requestFiltering>
                    <requestLimits maxAllowedContentLength="30000000"  />
                </requestFiltering>
            </security>
            <httpProtocol>
                <customHeaders>
                    <remove name="X-Powered-By" />
                    <remove name="server" />
                </customHeaders>
            </httpProtocol>
        </system.webServer>
    </configuration>
    

    我应该删除“位置”节点吗?还是应该在我的 web.config 中添加其他内容?

    【讨论】:

    • 您遇到了服务器错误。因此,您需要启用详细错误以获取有关错误的更多信息。看到这个帖子stackoverflow.com/q/47134657/8011544
    • 感谢您的评论,我会记住它以应对未来的错误情况。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-11-06
    • 1970-01-01
    • 1970-01-01
    • 2020-09-12
    • 2020-08-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多