Web App Service returns 500 Internal Server Error when accessing API endpoints

Vinícius Lemos De Oliveira 5 Reputation points
2023-06-10T04:08:41.4733333+00:00

Hello,

I am currently facing an issue with my Web App Service that is connected to a GitHub repository containing my .NET project. The project itself is also connected to an Azure MySQL database. Unfortunately, every request I make to the Web App Service's URL results in a 500 Internal Server Error.

Here are some important details:

The project functions correctly when compiled and run locally, even when connected to the remote database. The Web App Service's Firewall settings are configured to allow all incoming requests. CORS (Cross-Origin Resource Sharing) is also properly configured to allow all origins.

Despite these settings, I am consistently encountering the 500 Internal Server Error when trying to consume the API using the service's URL.

I would greatly appreciate any assistance or suggestions to help resolve this issue. Please let me know if there are any additional details or configuration settings that I should consider.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,649 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,408 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. Sedat SALMAN 13,350 Reputation points
    2023-06-12T15:31:32.87+00:00

    Azure provides application logs that can be used to understand the exact cause of the issue. You can enable application logging from the "App Service logs" section in the Azure portal. Once enabled, you can access these logs and look for any exceptions or errors that might be causing the 500 Internal Server Error. Azure also provides diagnostic logs that can give you more detailed information about your application's operation and any errors that may have occurred. You can enable and view these logs from the "Diagnostic settings" section of your App Service in the Azure portal. Since your application works fine locally, but not when deployed to Azure, it's possible that there's a problem with your database connection. Ensure that your Azure MySQL database is properly configured and that your application has the correct connection string. Also, make sure your Azure MySQL server's firewall is set to allow connections from your App Service. Make sure that your application is being properly deployed to Azure from your GitHub repository. You can check the deployment logs in the "Deployment Center" section of your App Service in the Azure portal. Make sure that all the necessary dependencies are installed and that the runtime stack is compatible with your .NET project.

    0 comments No comments

  2. Anyman 1 Reputation point
    2024-07-26T00:19:34.0166667+00:00

    I wrestled with this issue for ridiculously long time and here is what was causing the 500 internal server error for me: In azure sql server, navigate to security -> networking. In there under public access tab, there is a small checkbox on the very bottom of the page that states "Allow Azure services and resources to access this server". This is unchecked by default. Checking this box solved the issue for me. Hope this helps someone else out there to save some time!

    0 comments No comments