azure Web App (running ASP.NET (MVC) seems like it does not recognise or detect azure SQL server and database

Niklas Stokke 0 Reputation points
2024-04-18T09:29:42.04+00:00

I have an Asp.NET mvc project running on an azure Web App. I also have a SqlServer with a Sql database connected. When using the sqlserver on a local project (WPF app) it gives me the data. When I try to use it on the Webapp i just get an error message when i enter the Index of the CRUD methods created.

The fault I get are very vague and I am stuck. "Win32Exception: The system cannot find the file specified. Unknown location"

and

"SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.) Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, bool breakConnection, Action<Action> wrapCloseInAction)"

Azure SQL Database
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
766 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 15,446 Reputation points
    2024-04-18T09:49:09.7933333+00:00

    Based on this old thread :

    It is a normal issue, you may try the following techniques:

    Make sure your database engine is configured to accept remote connections:

    • Start > All Programs > SQL Server 2005 > Configuration Tools > SQL Server Surface Area Configuration
    • Click on Surface Area Configuration for Services and Connections
    • Select the instance that is having a problem > Database Engine > Remote Connections
    • Enable local and remote connections
    • Restart instance

    You may need to create an exception on the firewall for the SQL Server instance and port you are using:

    • Start > Run > Firewall.cpl
      • Click on exceptions tab
      • Add sqlservr.exe (typically located in C:\Program Files (x86)\Microsoft SQL Server\MSSQL.x\MSSQL\Bin, check your installs for the actual folder path) and port (default is 1433)
      • Check your connection string as well
      • From [FIX : ERROR : Could not open a connection to SQL Server]:

    Then Check if your SQL server services is up and running properly:

    • Go to All Programs > Microsoft SQL Server 2008 > Configuration Tools > SQL Server Configuration Manager > SQL Server Services
      • Check to make sure SQL Server service status is Running.

    In addition, ensure that your remote server is in the same network. Run sqlcmd -L to ascertain if your server is included in your network list.

    Enable TCP/IP in SQL Server Configuration :

    When two or more SQL Servers are connected across network they do all communication using TCP/IP. The default port of SQL Server installation is 1433. This port can be changed through SQL Server Configuration Manager. TCP/IP should be enabled for SQL Server to be connected.

    • Go to All Programs >> Microsoft SQL Server 2008 >> Configuration Tools >> SQL Server Configuration Manager >> Select TCP/IP
    • Right Click on TCP/IP >> Click on Enable

    You must restart SQL Server Services for all the changes to take effect. Right click and go to menu properties to select location where default port of SQL Server can be changed.

    More links :

    https://learn.microsoft.com/en-us/troubleshoot/sql/database-engine/connect/network-related-or-instance-specific-error-occurred-while-establishing-connection https://learn.microsoft.com/en-us/azure/azure-sql/database/troubleshoot-common-errors-issues?view=azuresql

    0 comments No comments