sql-serverangularazureasp.net-corehttp-status-code-500

Http 500 error : ASP.NET Core, Angular SQL Server database


I have an application that runs fine locally, using ASP.NET Core, Angular and a SQL Server database.

But, I am having problems when trying to deploy it. I have the SQL Server database deployed to Azure. The backend is also deployed to Azure.

I am running the frontend locally to test the backend /database. Any calls that it makes to the database return a http 500 error. I have also tried to use Postman to hit the endpoints, and I also get a http 500 error. It didn't show any errors when I published it and it showed that it should run. When I publish the solution it shows the database is connected:

Azure publish

You can see from the screen print that I have connected application insights also but it hasn't given me much information.

This is in Azure showing where the error was thrown, but I don't know where this is in my code:

erroring part of code

These are the calls that get a 500 error they are both making calls to the database:

Failed calls

Here is the inspect from the locally running front end:

network inspect

I followed this tutorial to deploy but I am not sure that the information it gave to connect the database to my API applied to the Stack I am using.

https://www.youtube.com/watch?v=u_CRppLcC9k&t=463s

Thank you in advance for any direction or help you can give me. I have been stuck on this for about a week. Here is a screenshot of the rules for the firewall that have my api Firewall Rules

here is a screenshot of the log stream I blocked out my ip address and the URL to the API.

logstream This is the app log stream:

app log stream

What does this mean: >IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly.

  • IIS was not able to process configuration for the Web site or application.
  • The authenticated user does not have permission to use this DLL.
  • The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.


  • Solution

  • I finally was able to get my deployed Back End Services to connect to my deployed Azure SQL DB. I did a few things. I am not sure which exact item fixed my 500.0 error I was receiving.

    1. I read in the Microsoft documentation that if both your service and your database were in Azure you didn't need to put the IPV4 output range for the Web Api as a firewall rule for the DB server. You can enter 0.0.0.0 for the start and end 0.0.0.0
    2. The second thing I changed was I had been using the service connector in addition to putting a connection string in my appsettings.json. I deleted those connections in the service connector and in Visual Studio. VS screen shot of service dependencies
    3. I had forgotten that every time I changed to a different connection string and then published the app again it didn't overwrite the service dependencies, it created additional service dependency files. Service Dependencies So I deleted all of the service dependencies and any additional files created by publishing to Azure. I discarded the changes in my Git version control in VSCode. I made sure I had the first option connection string for ADO.NET (Microsoft Entra passwordless authentication) I made sure I created an admin in the Microsoft Entra Id following these instructions: https://learn.microsoft.com/en-us/azure/app-service/tutorial-connect-msi-sql-database?tabs=windowsclient%2Cefcore%2Cdotnet#grant-permissions-to-managed-identity Then I gave the DB access to it. I then published that and it worked!