0
votes

It works perfect when I run in Local and SQL Azure DB. But when I publish the website to azure it gives me error as following.

My web Config:

<configuration>
  <connectionStrings>
    <add name="systemReposConnectionString" connectionString="Server=tcp:ewsserver.database.windows.net,1433;Database=systemRepos;User ID=xxxdb@ewsserver;Password=xxxx;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>

    <customErrors mode="Off"></customErrors>
    <compilation targetFramework="4.5" debug="true"/>
    <httpRuntime targetFramework="4.5" />
  </system.web>



</configuration>

Error that I get as below: 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: 26 - Error Locating Server/Instance Specified)

I have set the firewall setting for my azure SQL server from 0.0.0.0 and 254.254.254.254

Thanks

2

2 Answers

3
votes
  • Go to Azure portal > Your SQL server > Firewall Settings
  • Look for 'Allow access to Azure services'. Make sure 'On' is selected.

This would allow the other Azure services to reach the SQL server, without the need to set the allowed IP range on the your Azure Website's web config. A normal connection string will suffice.

0
votes

CONFIGURING ALLOWED IP ADDRESSES There are three points that must be configured in Web.config:

  • Set the allowUnlisted option to “false”.
  • Set the denyAction to“Unauthorized”.
  • Add a line for each allowed IP address or network. enter image description here

This configuration will allow access from both the local machine and the 10.200.7.x network, this however is only half of the story as the IP addresses that Azure and AWS use are vast and numerous, they are also published online.

For more Information ,please refer https://azure.microsoft.com/en-us/blog/ip-and-domain-restrictions-for-windows-azure-web-sites/