2015-10-16 67 views
0

這是我第一個在Azure上託管數據庫的MVC網站。MVC網站無法連接到Azure上的數據庫

我已經部署了數據庫和網站。不過,我得到一個訪問被拒絕錯誤消息:

[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)]

我不明白的是,我可以運行通過Visual Studio中通過Azure的連接字符串連接在本地沒有任何問題的應用程序。我可以遠程地與數據庫通話,但不能在Azure中使用!

下面是我使用的連接字符串:

<connectionStrings> 
    <add name="myConnString" 
    connectionString="metadata=res://*/Models.MyModel.csdl|res://*/Models.MyModel.ssdl|res://*/Models.MyModel.msl; 
    provider=System.Data.SqlClient; 
    provider connection string=&quot; 
    Data Source = tcp:mybdurl.database.windows.net,1433;Initial Catalog=myDb; 
    persist security info=True; 
    User ID=MyId; 
    Password=MyPassword; 
    MultipleActiveResultSets=True; 
    application name=EntityFramework&quot;" 
    providerName="System.Data.EntityClient" 
    /> 
</connectionStrings> 

我猜有允許訪問缺少魔法Azure的元素。兩者都位於同一個數據中心並在同一個帳戶中。

乾杯

+0

在Azure門戶>數據庫>配置中是否允許「Windows Azure服務」? –

+0

是的設置爲'是' – ComfortablyNumb

+1

這很奇怪。也許你的Azure門戶連接字符串是錯誤的,但你的web.config字符串是正確的(看&和")?這可能會導致這個問題 –

回答

0

我被單獨發佈在Visual Studio中web.config文件,並沒有意識到它實際上並沒有更新Azure上。我回到了老式的FTP,而實際上web.config仍然是Azure的原始版本。

手動上傳它,它的工作!

什麼沒有它公佈?

相關問題