Azure App Service running .net 5 API displaying Runtime error

bisondev 26 Reputation points
2021-10-14T03:10:35.74+00:00

Hi All,

I have recently deployed my .NET 5 API to an Azure App service, running .NET 5 as well. I have set up a CI/CD pipeline and release pipeline in Azure DevOps, which runs without issue. However when I try to access my API from the URL (which should open a swagger page), I see this:

140431-image.png

I have followed the instructions on the screen and modified my web.config so that it looks like the following:

140357-image.png

However I still see the same message when I try to visit my API. I am developing on a windows machine, using Kestrel, and I have no problems locally. I have checked the web.config on the App Service itself and it looks the same as my local web.config. The Azure App Service OS is: Microsoft Windows NT 10.0.14393.0.

I would really appreciate any assistance here! I've been stuck on this problem for a while and the other posts that I have reviewed on this topic haven't helped much... Thanks in advance!

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ryan Hill 30,281 Reputation points Microsoft Employee Moderator
    2021-10-15T16:03:37.06+00:00

    First thing is to enable logging on your app service; see https://learn.microsoft.com/en-us/azure/app-service/troubleshoot-diagnostic-logs to enable those logs. This will give you a better idea of what the runtime exception is. .NET Core bootstrapped project will have the following snippet in the ConfigureServices method in the Startup class.

       if (env.IsDevelopment())  
                   {  
                       app.UseDeveloperExceptionPage();  
                   }  
    

    Adding ASPNETCORE_ENVIRONMENT set to Development will show the developer style exception page rather than this one. However, it's not advised to leave this setting permanently as it can display sensitive information. With regards to your Swagger, make sure you've added UseSwaggerUI() middleware to your ConfigureServices method as well. Feel free to look at my Startup.cs for reference.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.