3

我的問題與SO上的this問題非常相似,但不完全相同。Azure SQL數據庫在本地運行時工作,但未在發佈到Azure時工作

當我在本地連接到我的天藍色數據庫時,它運行完美。但是當我部署到Azure時,似乎無法連接到數據庫。我首先使用了Entity Framework 5代碼,並且我還在EF 5參考中設置了copy local:true。

這是我的連接字符串:

<add name="api" connectionString=" 
    Server=tcp:[hidden].database.windows.net,1433;Database=API; 
    User ID=[hidden]@[hidden]; 
    Password=[hidden];Trusted_Connection=False; 
    Encrypt=True;Connection Timeout=30; 
    PersistSecurityInfo=True;" providerName="System.Data.SqlClient" /> 

    <add name="Membership" connectionString=" 
    Server=tcp:[hidden].database.windows.net,1433; 
    Database=Membership;User ID=[hidden]@[hidden]; 
    Password=[hidden];Trusted_Connection=False; 
    Encrypt=True;Connection Timeout=30; 
    PersistSecurityInfo=True;" providerName="System.Data.SqlClient"/> 

我在web.config文件中添加

<customErrors mode="Off"/> 

所以我可以看到堆棧跟蹤,這些都是我得到的例外:

[TargetInvocationException: Exception has been thrown by the target of an invocation.] 
[InvalidOperationException: The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588] 
[ProviderIncompatibleException: An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. 

當讀取堆棧跟蹤時,肯定會問題是我無法初始化成員資格數據庫。這必須是一個Azure的部署問題,但我似乎無法推測出來..

編輯:

的API,數據庫現在的工作,但會員給出了同樣的錯誤。我縮放了網站而不是共享。不知道這是否會產生任何影響。

FIXED:

嗯,這是纔怪..突然,網站有兩種數據庫連接。沒有做任何其他更改服務器從共享保留..

+0

我假設你已經設置SQL Azure的防火牆以允許Windows的範圍內Azure服務? – JuneT 2013-03-07 15:21:51

+0

是的,我已經設置它允許Windows Azure服務:) – 2013-03-07 15:31:08

回答

0

請確保您的IP地址在數據庫允許的IP地址列表中。

+0

參考上面的評論:) – 2013-03-08 13:09:53

3

檢查IP規則上的Windows Azure門戶網站製作,並確保您的IP地址是允許你訪問數據庫運行在Windows Azure上

+0

我做到了。爲了測試,我甚至添加了從0.0.0.0-255.255.255.255範圍內的IP地址。仍然沒有工作:( – 2013-03-08 13:09:35

相關問題