Azure App Services: Determine supported dotnet core version

If you try to use the latest .NET Core version 2.1.3 within your Azure Web or API App, you will receive the error code 502.5.

After you enabled logging you will find an error similar to this:

It was not possible to find any compatible framework version
The specified framework 'Microsoft.AspNetCore.App', version '2.1.3' was not found.
  - Check application dependencies and target a framework version installed at:
      D:\Program Files (x86)\dotnet\
  - Installing .NET Core prerequisites might help resolve this problem:
      http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
  - The .NET Core framework and SDK can be installed from:
      https://aka.ms/dotnet-download
  - The following versions are installed:
      2.1.0-rc1-final at [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App]
      2.1.2 at [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App]

So one way to determine the installed dotnet core versions is to look at the error log. But you can also execute the following command within the Debug Console on the Kudu Engine (Advanced Tools in the Azure Portal):

dotnet --list-sdks

This will displays the installed .NET Core runtimes:

dotnet-list-sdks

Automatically pick the latest dotnet core version

You can simply avoid running into this error by omitting the Version attribute on the Microsoft.ApsNetCore.App PackageReference within your Project file (*.csproj):

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Folder Include="wwwroot\" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App"/>
  </ItemGroup>
</Project>

Now, as soon as the Azure App Services gets the new 2.1.x dotnet core sdk, your app will automatically start using it.

Determine whats wrong with your Azure Web / API App deployment

Sometimes a deployment goes wrong and instead of the actual app you get a message like this:

An error occurred while starting the application.
.NET Core 4.6.26020.03 X86 v4.0.0.0 | Microsoft.AspNetCore.Hosting version 2.0.1-rtm-125 | Microsoft Windows 10.0.14393 | Need help?

To see whats going wrong we have to enable logging:

  • Go to the Kudu environment (https://YOURSITE.scm.azurewebsites.net)
  • On the top menu, select Debug console -> PowerShell
  • Navigate to site -> wwwroot and open the web.config
  • Set the stdoutLogEnabled attribute to true and save the file. Example:
  • <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    	<system.webServer>
    		<handlers>
    			<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    		</handlers>
    		<aspNetCore processPath="dotnet" arguments=".\MyApp.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
    	</system.webServer>
    </configuration>
    
  • Create a folder named logs next to the web.config using mkdir logs

Now if you try to browse your site again, you should see a log file within the previously created directory containing additional information:

kudu