建立並部署一個串連SQLAzure的WindowsAzure應用遇到的問題及解決辦法

來源:互聯網
上載者:User

一、使用WindowsAzure開發的系統內容:

作業系統:Windows 7

開發環境:VS 2010(安裝有必要的工具)

 

二、相關資料及其地址:

1、WindowsAzureSDK和針對VS2010的工具。:http://www.microsoft.com/downloads/en/details.aspx?FamilyID=7a1089b6-4050-4307-86c4-9dadaa5ed018&displaylang=en

 

2、WindowsAzure開發人員中心,上面有些簡單的入門樣本。:http://msdn.microsoft.com/zh-cn/windowsazure/

 

3、WindowsAzure的管理中心,使用Windows
Live ID登入即可。地址:https://windows.azure.com/

 

4、SQLAzure的管理中心,使用Windows
Live ID登入即可。地址:https://sql.azure.com

 

三、開發WindowsAzure串連SQLAzure資料及部署過程

1、開啟SQLAzure的管理中心,建立一個資料庫。使用sqlcmd工具串連剛才建立的資料庫,就可以操作資料庫了。另外,使用
SQL Server 2008 Management Studio R2也可串連SQLAzure資料庫,:http://www.microsoft.com/downloads/zh-cn/details.aspx?displaylang=zh-cn&FamilyID=56ad557c-03e6-4369-9c1d-e81b33d8026b。

 

比如:

C:/Users/Administrator>sqlcmd -U [username]@[ServerName] -P password -S [ServerName].database.windows.net
-d master

1> create database dbtest;

2> go

1>  quit

2>   

2、建立一個WebRole工程(“WindowsAzure開發人員中心”有例子作為參考,此處省略),刪除不必要的檔案,添加增刪改操作資料庫的代碼,串連SQLAzure資料庫可以使用ADO.NET,只是資料庫連接字串需要修改為: 

Server=tcp: [ServerName].database.windows.net;Database=dbtest;User
ID=[username]@[ServerName];Password=[password];Trusted_Connection=False;Encrypt=True;

 

3、發布該WindowsZruze工程,產生上傳包(請參考“WindowsAzure開發人員中心”)。

4、上傳到WindowsAzure管理中心。

 

四:期間遇到的問題及解決辦法

1、本地調試時候,遇到串連SQL
Azure資料庫錯誤的問題。

解決辦法:在SQLAzure管理中心把原生IP添加“防火牆設定”中。

 

2、部署到WindowAzure上後,遇到串連SQLAzure資料庫錯誤的問題。

解決辦法:在SQLAzure管理中心把提示的AzureClient的IP添加“防火牆設定”中。

 

3、在Windows
7和IIS 7.0中,建立Web應用後,VS2010中調試正常,但是發布到IIS7.0的某一個“虛擬目錄”後,提示“未能載入類型WebTest._Default”的錯誤。

解決辦法:在IIS7.0中另外建立一個WebSite,其實體路徑指向Web應用,其應用程式集區的.NETFrameWork的版本選擇和Web應用使用的版本一致,比如,都是.NETFrameWork
4.0。然後,執行C:/Windows/Microsoft.NET/Framework/v4.0.30319>aspnet_regiis.exe –i

 

4、部署到WindowsAzure後,看不到詳細的錯誤提示,請臨時把指定禁用自訂錯誤允許顯準的詳細錯誤),錯誤排除後仍修改為RemoteOnly。

  <system.web>    <customErrors mode="Off"></customErrors>      </system.web>

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.