2012-07-18 123 views
0

我試圖從託管在Azure中的服務訪問公司內部存在的SQL數據庫。 這是我曾嘗試:在Azure上託管的Web應用程序訪問本地SQL數據庫

  1. 創建的本地服務器上的MS SQL數據庫
  2. 創建示例Web應用程序(Windows Azure雲服務)
  3. 修改Web.config文件有正確的SQL連接串
  4. 使用激活令牌從Azure管理激活Web門戶的作用
  5. 安裝本地端點在本地服務器上
  6. 發佈的Web應用程序天青
  7. 使用Web角色和OCAL端點
  8. 啓動試圖從數據庫中讀取記錄的應用
  9. 創建端點組。

提示以下錯誤:試圖使用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) 

請幫助。

+0

它與Compute Emulator而不是Azure兼容嗎?你測試過你的連接字符串了嗎? – 2012-07-18 07:43:38

+0

你可以告訴我們你的連接字符串(剝離出密碼/用戶等敏感信息)嗎?確保您的本地SQL Server配置了組合身份驗證,並且您有用於連接的SQL Server用戶。 – astaykov 2012-07-18 07:46:45

+0

它可以與Compute Emulator一起使用。 – Ripin 2012-07-18 08:26:41

回答

0

Trusted_Connection必須爲false。您無法從Azure進行Windows身份驗證。

+0

從外部打開SQL端口並將連接字符串修改爲Trusted_Connection = false後工作正常 感謝您的幫助! – Ripin 2012-07-18 10:39:57

+0

你現在可以。 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 – Will 2013-05-08 14:07:33

相關問題