0

I am trying to access the SQL database that exist in the company premises from the service hosted in Azure. This is what I have tried:

  1. Created MS SQL database on local server
  2. Created the sample web application (Windows Azure Cloud Service)
  3. Modify the web.config file to have the correct SQL connection string
  4. Activate the web role using Activation token from Azure Management portal
  5. Install the Local endpoint on the local server
  6. Publish web application to Azure
  7. Create endpoint group using web role and the ocal endpoint
  8. Launch the application
  9. Tried to fetch the records from database.

Getting the below error while trying to fetch the records from database using Azure:

System.Data.SqlClient.SqlException (0x80131904): 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)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
   at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity)
   at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject)
   at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout)
   at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
   at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
   at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.SqlClient.SqlConnection.Open()
   at WebRole1._Default.btnGetEmployee_Click(Object sender, EventArgs e)

Please help.

AdaTheDev
  • 142,592
  • 28
  • 206
  • 200
Ripin
  • 35
  • 5
  • Does it work with Compute Emulator instead of Azure? Have you tested your connection string? – Vasile Mare Jul 18 '12 at 07:43
  • can you show us your connection string (stripping out sensitive info like password/user). Make sure your local SQL Server is configured with Combined Authentication and you have SQL Server user which you are using to connect. – astaykov Jul 18 '12 at 07:46
  • It works fine with Compute Emulator. – Ripin Jul 18 '12 at 08:26
  • @astaykov Below is the connection string used: I am able to access the database using the username/password passed in the connection string, using SQL Server Management Studio. – Ripin Jul 18 '12 at 08:35
  • how about local FireWall on the Server where SQL is installed, which permits connections from outside it on Port 1433? And also SQL Server listening to IPv6? – astaykov Jul 18 '12 at 08:41

1 Answers1

1

Trusted_Connection must be false. You cannot do Windows Authentication from Azure.

Vasile Mare
  • 189
  • 9
  • Worked fine after SQL port open from outside and modifying the connection string to Trusted_Connection=false Thanks for all the help!!! – Ripin Jul 18 '12 at 10:39
  • You can now. http://weblogs.asp.net/scottgu/archive/2013/04/26/windows-azure-improvements-to-virtual-networks-virtual-machines-cloud-services-and-a-new-ruby-sdk.aspx –  May 08 '13 at 14:07