azure-web-app-serviceazure-deployment-slots

How to debug Azure app service slot swap failure


I am getting the following error when trying to do a slot swap for our app service:

##[error]Error: Failed to swap App Service 'service1' slots - 'staging' and 'production'. Error: BadRequest - Cannot swap slots for site 'service1' because the application initialization in 'staging' slot either took too long or failed. Please check AppInit module configuration or try using swap with preview if application initialization time is very long. (CODE: 400)

This is what our web.config file looks like:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\XXXXXXXXXX.Services.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
      <security>
        <requestFiltering>
          <requestLimits maxAllowedContentLength="1073741824" />
        </requestFiltering>
      </security>
      <applicationInitialization>
        <add initializationPage="/api/warmup" />
      </applicationInitialization>
      <tracing>
        <traceFailedRequests>
          <clear />
          <add path="/api/warmup">
            <traceAreas>
              <add provider="ASP" verbosity="Verbose" />
              <add provider="ASPNET" areas="Infrastructure,Module,Page,AppServices" verbosity="Verbose" />
              <add provider="ISAPI Extension" verbosity="Verbose" />
              <add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,Rewrite,iisnode" verbosity="Verbose" />
            </traceAreas>
            <failureDefinitions statusCodes="200-600" />
          </add>
        </traceFailedRequests>
      </tracing>
    </system.webServer>
  </location>
</configuration>

The API that is used for initialization and tracing - /api/warmup - this is functioning with no issues, I am able to invoke the API manually in both the production and staging slot, successfully. In fact, in the pipeline file, I invoke this API prior to invoking the slot swap task, yet the slot swap task fails after about 45 seconds.

Further, no trace file is generated in the /LogFiles folder, and I'm not sure where next to look. I would assume a trace file would be created even when I manually invoke the API, but it's not being created, so is there maybe an issue with the web.config file?


Solution

  • I figured the issue - i had Configuration key WEBSITE_SWAP_WARMUP_PING_STATUSES set to 200,202. Once I removed the key, the swap completed successfully.