title: Troubleshooting 500.31 ANCM on Azure App Service
body: <p>After upgrading a project from <strong>ASP.NET Core 3.0</strong> to <strong>ASP.NET Core 3.1</strong>, my application stopped working on <strong>Azure App Services</strong>—but <em>only</em> when published using <em>continuous deployment</em> from <strong>Azure DevOps Pipelines</strong>. (<a href="https://stackoverflow.com/questions/58191849/how-to-implement-dotnet-core-3-0-in-devops-project">Similar to another question</a>, it continues to work if I publish directly from Visual Studio.)</p>
  <p>Specifically, the pipeline is still able to publish using the <em>Azure App Service Deploy</em> (<code>AzureRmWebAppDeployment</code>) task, but it fails to load in the Azure App Service environment with a <a href="https://docs.microsoft.com/en-us/aspnet/core/test/troubleshoot-azure-iis?view=aspnetcore-3.1#50031-ancm-failed-to-find-native-dependencies" rel="nofollow noreferrer">500.32 exception</a>:</p>
  <blockquote>
  <h2>500.31 ANCM Failed to Find Native Dependencies</h2>
  <h3>Common solutions to this issue:</h3>
  <p>The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found.</p>
  </blockquote>
  <p>Now, I'm quite familiar with this error for cases where the .NET Runtime is not installed, as is common immediately after Microsoft releases new versions. In those cases, the typical solution is to either:</p>
  <ol>
  <li>Publish as a <code>--self-contained</code> version of the application, or to</li>
  <li>Enable the appropriate runtime as an <em>App Service Extension</em>, if available.</li>
  </ol>
  <p>In this case, I <em>know</em> the .NET Core 3.1.2 runtime is available in the App Services environment, and have additionally confirmed that these solutions don't resolve the issue. This indicates a different underlying error.</p>
  <p><a href="https://stackoverflow.com/a/59465599/3025856">Other threads suggest looking for those details in the Windows Event Viewer</a> (<a href="https://github.com/dotnet/aspnetcore/issues/14443" rel="nofollow noreferrer">and here as well</a>). Since this is an Azure App Service, I instead looked in the <strong>App Service Logs</strong>. Those only included a copy of the above error, however, without any further details. Further, there are no exceptions logged in <strong>Azure Application Insights</strong>, suggesting this error is occurring prior to Application Insights loading.</p>
  <p><strong>Given this, my question: How do I troubleshoot 500.31 errors on an Azure App Service?</strong></p>