'How do you deploy WireMock.Net as an Azure Web App

I am trying to deploy a ASP.NET 6 App which contains WireMock.NET as a hosted service. According to WireMock.NET's wiki this is possible and I'm basically using a copy of this example provided.

But when deployed as an Azure Web App, it returns a 404 rather than a response from WireMock.NET. What I should get back is:

enter image description here

The 404 makes sense to me because without specifying any URL/Port in the WireMock.NET config, WireMock.NET picks a random port. So requests coming in on Azure will be on port 80/443 but this won't be the port that WireMock.NET is listening on.

The image above was taken from this GitHub issue/question where someone was having the exact same issue as me. They tried to configure WireMock.NET to listen on 80/443, but this prevents the app from starting up because the Azure Web App itself is using these ports.

As far as I'm aware you cannot configure Azure Web Apps to do port forwarding, i.e. to forward requests from port 80 to a port WireMock.Net is listening on.

Unfortunately (for me) the person with the issue/question managed to get it working, but it's not clear from the GitHub issue how exactly.

So the question is basically: how can I achieve this screenshot? Or, how do you deploy a hosted service (like builder.Services.AddHostedService<WireMockApp>();) that listens on the same port as the app itself?



Solution 1:[1]

The specified CGI application encountered an error and the server terminated the process

  • In Azure portal => Configuration => Application Settings, add the below setting
WEBSITE_LOAD_USER_PROFILE = 1
  • Right Click on the project => click on the publish button.
  • Select the publish profile which you downloaded from Azure.
  • Change the deployment mode under Summary to Self-Contained.
  • Click on publish button

enter image description here

  • Restart the app and check once

Please refer MS Q&A for more information

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 HarshithaVeeramalla-MT