2

Hoping someone can help out with this issue:

I've deployed my .NET Core 3.0 application on Azure, and even though the it it shows "Publish Succeeded." the application isn't loading (http 500, server error). The "Diagnose and solve problems" tab in Azure point to the module "AspNetCoreModuleV2" as shown in picture Azure - Diagnose and solve problems

I've tried:

  • Installing the .NET 3.0 Runtime Hosting Bundle as suggested here aspNetCore 2.2.0 - AspNetCoreModuleV2 error

  • Changing the modules="AspNetCoreModuleV2" to modules="AspNetCoreModule" on the web.config file, but the file reverts back to its original values once I publish the app.

  • Adding <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> to the csproj but it didn't make a difference so I've deleted that

Here is my current csproj file:

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

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>

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

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.0.1">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.6" />
    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.0.1" />
    <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.1.0-preview1-final" />
  </ItemGroup>

</Project>

In this is what my 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=".\SportsStore.dll" stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
</configuration>
<!--ProjectGuid: 3f1b616a-5c07-4b23-9c86-ec6506dc3fa7-->

By the way, the application runs without any issues in the local machine

Any help that can point me in the right direction is highly appreciated.

user12427270
  • 41
  • 1
  • 1
  • 5

5 Answers5

10

Edit your csproj

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
    <AspNetCoreModuleName>AspNetCoreModuleV2</AspNetCoreModuleName>
..

in this way during dotnet publish the TransformWebConfig task transforms your web.config as following, which works also in Azure WebApp

<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\assembly.dll" hostingModel="OutOfProcess" />
    </system.webServer>
  </location>
</configuration>

In Azure WebApp the HTTP Error 500.31 - ANCM Failed to Find Native Dependencies error it seams to be cause by InProcess hosting model and module AspNetCoreModuleV2

c-romeo
  • 388
  • 4
  • 13
  • Thanks for your tip... This line resolved my problem here. I was for 4 day getting 405 cors error anda after all those days, getting this tip to finally resolve my problem. – Olivertech Aug 11 '23 at 00:24
2

I've tried publishing as "self-contained" and modifying the web.config, however, nothing worked.

After further research I've found out about the "App Service Editor" tool in Azure. Having a look to the output errors I've realised the issue was to do with the database firewall blocking "my" IP. I had added a rule with my IP previously, however, the IP shown in the error message was different to my actual IP, for some reason. Once the I added another rule on the database with this IP, it worked immediately.

Another strange thing is that the error reported by the "Diagnose and solve problems" tool (AspNetCoreModuleV2) had not much to do with the actual issue.

Thanks everyone for taking the time to answer my question.

user12427270
  • 41
  • 1
  • 1
  • 5
  • Configured the firewall on my Key Vault to allow access from "Selected networks" only, which triggered error "500.30 In-Process Startup Failure" on my .NET Code 3.0 app. Switching Key Vault FW back to All Networks fixed the issue. – Jussi Palo Dec 09 '19 at 13:28
1

Have a check under the PublishProfiles folder (inside Properties) and ensure you have :

<SelfContained>true</SelfContained>

A self-contained application distributes the runtime with the application.

jazb
  • 5,498
  • 6
  • 37
  • 44
0

You can try change web.config directly on Azure, so when you deploy application go to the web.config and replace AspNetCoreModuleV2 to AspNetCoreModule. Changing web.config directly will restart application poll, just to understand what is problem.

Please see same article, with possible solutions:

AspNetCore 3.0 - HTTP Error 500.0 - ANCM In-Process Handler Load Failure

Emin Mesic
  • 1,681
  • 2
  • 8
  • 18
  • I thought about doing something like, however, I’m not sure where to find the web.config directly in Azure? – user12427270 Nov 25 '19 at 06:12
  • I think it's not easy to change, otherwise did you try to deploy application as Self-Contained? – Emin Mesic Nov 25 '19 at 06:20
  • I was trying to avoid deploying as self-contained, as it doesn’t seem to be the best option (based on the documentation at the Microsoft website) but I’m thinking I’ll have to try that... – user12427270 Nov 25 '19 at 07:38
0

What worked for me, after spending many hours, I'm using VS 2022. I hope it helps someone else.

In web.config, I changed "inprocess" to "OutOfProcess"

  <aspNetCore processPath="dotnet" arguments=".\myappdemo.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess" />
Steve42
  • 211
  • 2
  • 5
  • 10