asp.net on windows azure cloud service (updated)
DESCRIPTION
TRANSCRIPT
#GlobalWindowsAzure
#GlobalWindowsAzure
實戰 ASP.NET 雲端服務小朱
Windows Azure MVP
MCSD: Web Applications
studyazure.com 雲端學堂
#GlobalWindowsAzure
Global bootcamp?• 全球超過 60 個地方在同一天同時舉行。
或許可能是目前全球最大的社群活動
#GlobalWindowsAzure
全球合作夥伴
#GlobalWindowsAzure
全球研討會支援• http://globalwindowsazure.azurewebsites.net• 主題專家聊天室 https://jabbr.net/#/
rooms/GlobalWindowsAzure
#GlobalWindowsAzure
大綱• Windows Azure 生態系統• 雲端服務介紹• 更新與高可用域• 實作: Hello World (Web Role)• 實作: MVC Self-hosting (Worker Role)• 在 Web Application 間共用 Session• 實作:在 Web Application 間共用 Session
#GlobalWindowsAzure
ManagementComplexity
Windows Azure 生態系統
Web Sites
Cloud Services Virtual Machines
Control
素材庫
SPA
社群 N-Tier
分享
LOB
Web API 特定功能
傳統平台
混合平台
快取 存取控制
服務匯流排 CDN
流量管理員
高效能運算 儲存
本地環境
MediaServices
SQL Database
Flexibility
Hello World! .
Mobile Service
SQLReporting
Add-On
#GlobalWindowsAzure
雲端服務介紹
#GlobalWindowsAzure
為何使用雲端服務 ?
建立具無限擴展能力的應用程式與服務。
支援更豐富的多層應用程式。
自動化應用程式管理。
#GlobalWindowsAzure
何謂雲端服務
相關服務角色的集合
Web Role Worker Role
#GlobalWindowsAzure
能執行什麼 ?
#GlobalWindowsAzureWeb Role
所有 Worker Role 提供的功能 + IIS 7, 7.5 或 IIS 8.0*ASP.NET 3.5 SP1, 4.0 或 4.5* – 64bit可掛載Webforms 或 MVCFastCGI 應用程式 (e.g. PHP)多重網站
Http(s)Web/Worker 混合可選擇性的實作 RoleEntryPoint
*for Windows Server 2012
#GlobalWindowsAzureWorker Role 模式
佇列輪詢程式在 while(true) 迴圈中,輪詢與取出訊息進行處理。E.g. Map/Reduce 模式,背景影像處理。
聆聽程式建立 TcpListener/WCF Service Hosting/ASP.NET Web API Self-host.E.g. 執行 .NET SMTP Server 或 WCF Service 。
啟動外部行程於 OnStart 或 Run 方法執行 Process.Start()使用 Startup Task 安裝或執行外部程式。自訂角色進入點 ( 執行檔或 .Net 組件 )E.g. 執行 Database Server, Web Server 或是分散式快取伺服器。
#GlobalWindowsAzure角色生命週期所有角色都可以繼承自 RoleEntryPoint角色透過 RoleEnvironment 回報狀態
StatusCheck
StatusCheck
StatusCheck
Stopping
METHODS EVENTS STATUS
#GlobalWindowsAzure角色與執行個體
在執行期,角色會執行在一個或多個執行個體內 角色執行個體是由程式碼,組態檔與本地資料的集合,且部署在專屬的 VM 。
角色是定義在 Hosted 服務內一個角色的定義會指定 :VM 大小通訊終端點本地儲存資源etc.
#GlobalWindowsAzure
角色與執行個體
雲端服務Web Roles Worker Roles
Web_instance_0
Web_instance_1
Worker_instance_2
Worker_instance_1
Worker_instance_0
#GlobalWindowsAzure失效領域 (Fault Domain)
99.95% 的上線保證每個角色都必須要有兩個以上的執行個體。
角色執行個體會以 Fault Domain來隔離失效領域隔離虛擬機器失效領域提供贅餘能力每個角色至少要兩個失效領域
#GlobalWindowsAzure角色與執行個體示範:在三個 Fault Domain 中有九台虛擬機器
ROLE
VM1 VM3
VM5 VM8
VM2 VM4
VM6 VM9
VM6 VM9
#GlobalWindowsAzure更新領域
#GlobalWindowsAzure
建立雲端服務Lab Exercise 1-1
#GlobalWindowsAzure
部署雲端服務
#GlobalWindowsAzure了解封裝與組態Windows Azure 服務由下列兩種組態描述 :服務定義檔 (*.csdef)服務組態檔 (*.cscfg)
您的程式碼會與組態定義封裝在一起 (*.cspkg)Encrypted(Zipped(Code + *.csdef)) == *.cspkg
Windows Azure 只使用 (*.cspkg + *.cscfg)
#GlobalWindowsAzure
Startup tasks安裝軟體與功能組態主機 (host) 環境啟動行程
遠端桌面支援需要憑證以啟用遠端存取支援
終端點公開終端點內部終端點執行個體輸入終端點
執行期設定
#GlobalWindowsAzure
上傳到 Windows Azure
封裝與部署Microsoft
Visual Studio
Web Role
Worker Role
#GlobalWindowsAzure
應用程式升級策略轉置 (staging) vs. 生產 (production)轉置環境適用於測試與驗證 ; 利用 VIP 交換來提升到生產環境。
即地更新以新的部署來取代原有的部署。
#GlobalWindowsAzure
Role Instance
Windows Azure 診斷功能角色執行個體啟動診斷監控程式啟動監控程式設定完成在啟動時命令在任何時間於遠端進行組態會儲存在儲存區內。
監控程式將資料暫存在本地使用者可設定上限 (FIFO)
使用者初始化資料由本地到儲存區的傳輸排程 (Schedule)依需 (On Demand)
#GlobalWindowsAzure
部署雲端服務Lab Exercise 1-2
#GlobalWindowsAzure
在 Worker Role 中掛載 ASP.NET Web API Self-hosting Service
Lab Exercise 2
#GlobalWindowsAzure
Session 的處理
#GlobalWindowsAzure無狀態負載平衡器是以 round-robins 的方式在多個執行個體間傳送要求
下列為 Web Farm 的最佳實務作法不要在個別執行個體中儲存狀態 不要認為下一次的要求會在相同的執行個體中處理不要忘記像動態產生的影像是由網頁載入的事情
#GlobalWindowsAzure
Windows Azure Session State
Windows Azure 負載平衡器使用 RR 配置, Session State 必須儲存在用戶端或是每個要求都讀得到的儲存區內。
LBsession[“foo”] = 1; session[“foo”] = 2;
session[“foo”] 的值是 ?
SQL
DatabaseWindows
Azure Storage
#GlobalWindowsAzure處理 Session State
透過 Session State Provider 儲存 SessionWindows Azure CachingSQL AzureWindows Azure Storage
儲存到用戶端cookies
別忘記 ASP.NET MVC 的 TempData 是使用 Session State Provider 來儲存資料。
#GlobalWindowsAzure
在 Web 應用程式中共享 Session
Lab Exercise 3
#GlobalWindowsAzure
WATK 相關的資源簡報檔:
PRESENTATION-WindowsAzureOverviewPRESENTATION-WindowsAzureCloudServicesPRESENTATION-CloudServiceLifecycle
手作實驗:HOL-IntroToCloudServicesHOL-AdvancedWebWorkerRolesHOL-MigratingAspNetApps-VS2012HOL-DebuggingCloudServices-VS2012HOL-DeployingCloudServices-VS2012
https://github.com/WindowsAzure-TrainingKit/
#GlobalWindowsAzure
MSDN Windows Azure 線上資源Windows Azure 實作手冊:http://msdn.microsoft.com/zh-tw/jj590639Windows Azure 教學影片:http://msdn.microsoft.com/zh-tw/jj573849 Windows Azure Developer Center :http://www.windowsazure.com/en-us/documentation/
#GlobalWindowsAzure
Windows Azure 資源
Free Trial Link: http://www.windowsazure.com/en-us/pricing/free-trial/?WT.mc_id=WWE001_1032548834
MSDN Subscription Offer: https://www.windowsazure.com/en-us/pricing/member-offers/msdn-benefits/?WT.mc_id=WWE001_1032548834
BizSpark Offer: https://www.windowsazure.com/en-us/pricing/member-offers/bizspark-benefits/?WT.mc_id=WWE001_1032548834
MPN Offer: https://www.windowsazure.com/en-us/offers/ms-azr-0002p/?WT.mc_id=WWE001_1032548834
#GlobalWindowsAzure
2013/5/4 10:00-16:00張榮發基金會
國際會議中心 10F
微軟實戰課程日獨立專家,實用解答