Azure App service failing to connect to the Azure SQL VM Server

VAMSY KRISHNA REDDY 6 Reputation points
2022-11-07T08:29:56.457+00:00

The connection string of my .NET application to connect to the database has been provided in the configuration of an Azure App service and the database is present in an Azure SQL Virtual Machine, when trying to access the APIs of my application I see the following error,

“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: TCP Provider, error: 0 - Access is denied”

However, I am able to connect to the database via local system’s SSMS on VPN of our Organization with same credentials used as of connection string.
Appreciate if you could help!

SQL Server on Azure Virtual Machines
Azure App Configuration
Azure App Configuration
An Azure service that provides hosted, universal storage for Azure app configurations.
237 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,656 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. Ronen Ariely 15,191 Reputation points
    2022-11-07T08:50:26.657+00:00

    Hi,

    This is a very common issue and Microsoft provide a step-by-step Troubleshooting document. Please follow the link bellow:

    https://learn.microsoft.com/en-us/troubleshoot/sql/connect/network-related-or-instance-specific-error-occurred-while-establishing-connection?WT.mc_id=DP-MVP-5001699

    If you have specific step which is not clear then pls elaborate and we will provide more details :-)

    0 comments No comments

  2. Manu Philip 18,681 Reputation points MVP
    2022-11-07T08:52:27.983+00:00

    Following reference is an excellent example scenario describes how to securely connect a web app to a backend database over a fully private connection. The architectures ensure communication from the web app in Azure App Service and Azure SQL Database only traverses a virtual network.

    private-web-app

    Please have a look and see if it helps to resolve the issue

    ----------

    --please don't forget to upvote and Accept as answer if the reply is helpful--

    0 comments No comments

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.