0

I have created a demo Web Api in net6 using the Visual Studio 2022 template for that. The Web Api runs fine on my machine but when trying to host it in an Azure App Service it fails with the following error:

enter image description here

After some research I managed to have it working on Azure by changing the module "AspNetCoreModuleV2" to "AspNetCoreModule" in the web.config.

Here it is the web.config that gets deployed to Azure and it doesn't work:

<?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=".\Web6Test.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
</configuration>

Is it possible to host the web api in Azure using the "AspNetCoreModuleV2" module?

Bonomi
  • 2,541
  • 5
  • 39
  • 51

1 Answers1

0
  • There can be multiple reasons causing HTTP 500.30 error: ASP .Net core app failed to start like App Initialization, App Configuration and Key vault permission issues.

  • Thanks to 130nk3r5, I figured out how to find the root cause of the error:

  1. Go to Azure Portal
  2. Select App Services
  3. Search and click on your App service
  4. Go to development tools and open console.
  5. Run the application through this console and then the real error that is causing the application not to load will be displayed.
  • You can refer to this SO thread for multiple solutions.

  • Hosting the web api can also be achieved by using AspNetCoreModuleV2 in the web.config.

  • I have reproduced the same by creating a .Net 6.0 Core web API project in Visual Studio.

Web.config:

<?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=".\XXXXXX.dll" stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
</configuration>
<!--ProjectGuid: 09e5e23c-101e-41d1-bd27-60c6f5c08db0-->

Output when running the project locally:

enter image description here

  • Deployed the application to Azure App Service: enter image description here

Output after hosting the application in Azure App Service:

  • Result: enter image description here
Pravallika KV
  • 2,415
  • 2
  • 2
  • 7
  • There error you are showing in the screenshot above is different. In the end I managed to sort out the problem by deleting the "app service" in the Azure Portal, and create one from the Visual Studio Publishing menu instead of creating it on the Portal. Still don't know why it was not working when creating the "app service" from the Portal. – Bonomi Nov 07 '22 at 16:08
  • There are multiple reasons for Http Error 500:30 ASP net core app failed to start. I have updated the answer with additional information about how to figure out the root cause of the error. – Pravallika KV Nov 08 '22 at 08:54