web site in mvc can not connect to the database in azure sql


I have a site in mvc that connects to a database all mounted in Azure , when a local site test is done correctly, but when doing the deploy a Azure shows that you can not connect the site with DB .

the database firewall is enabled the connections to the azure services

The error is:


Catastrophic Error in / Login / LoginConfirmed


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 - An attempt was made to access socket in a way   forbidden by its access permissions.)

asked by ecodrive 25.01.2016 в 14:50

3 answers


You should validate how you define the connection string in the application

How to use Azure SQL Database in .NET applications

Use the option Show connection string to take the connection you would use in your development


answered by 25.01.2016 в 15:09

In the configurations tab of your web app there is a section that allows you to add connection strings that overwrite the web.config


Make sure the connection string has the same name as your web.config and generate a valid connection string.


answered by 01.02.2016 в 07:09

The same thing just happened to me, the solution is that you must go to the Azure firewall configuration.

Once there you must add the ip of the server from which you want to connect to the DB (The server where your Web application is).

Save the changes and that's it. Good luck.

answered by 11.02.2017 в 03:28