I have api appservice in my azure and also I have VM with SQL Server installed. Now I would like to connect to the database on the vm. I keep getting the following connection error when provide the connection string to api as :
Server=db-svr;Initial Catalog=DBName;Persist Security Info=False;User ID=userid;Password=password;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
System.AggregateException: One or more errors occurred. (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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server))
System.Data.SqlClient.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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
System.ComponentModel.Win32Exception: Access is denied
--- End of inner exception stack trace ---at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling)
My VM -> Overview : There is no DNS name configured and no public ipaddress. That is the reason I used computer name.
Also the VM->Networking has got the following inbound rule.
Can anyone help how to connect my app service to the SQL Server database available in this VM?
Thanks
