App to App Communication Skype Windows Azure Mobile
語音辨識 App to App Communication 離線地圖 Skype
使用Windows Azure Mobile Service
何謂雲端運算? 雲端運算 ≠ Web Solutions 雲端運算 ≠ ASP(Application Services Provider) 雲端運算 ≠ VM(Virtual Machine) 雲端運算 ≠ AJAX技術或類似的UI技術
WP 7有哪些典型的雲端應用情境? WP存取blob, table. . . 等Storage (App需要存取大量圖片、影像、或多媒體檔案 …etc) WP存取SQL Azure (App需要存取資料表…etc) WP登入Web Role(ASP. NET) (ex, 身分驗證、識別、加值資料存取) Worker Role的Routine Jobs (ex, Push Notification Process) …
架構圖 WP與雲端運算(資料存取) SQL Azure DB Web Role storage
架構圖 WP與雲端運算(身分驗證) ASP. NET Membership DB Web Role Azure ACS
架構圖 WP與雲端運算(訊息服務、動態磚更新 ) Microsoft Push Notification Service DB Worker Role Windows. Azure. Project 2 Windows Azure storage SQL Azure 建立基本Worker. Role-WP 7 Push Notification訊息發送
開發技術架構圖 WP可透過哪些技術存取雲端? Web Role REST API/WS ADO. NET EF Linq. To. Sql ADO. NET SQL Azure DB JSON/XML. NET Fx 4. 0 REST API Windows Azure storage
從Windows Phone存取Cloud 要熟悉SQL、XML、SOAP. . . 要學會REST API、JSON. . . 得明白ADO. NET EF, Linq. To. Sql, Linq. . . 會操作o. Auth、ASP. NET Membership. . . 必須擅長Silerlight、WCF Services. . . … 我們有Windows Azure Toolkit for Windows Phone 7(WAT) NO, 我們不會如此殘忍… & Azure Mobile Service
關於 關於Windows Azure Toolkit
WAT是什麼? ? ? Windows Azure Toolkit 簡化您由WP 7存取Windows Azure Storage (blob, table, queue), SQL Azure …等機制的應用程式開發套件 組。 包含您需要的Class Libraries(類別庫 )、Project Template…等資源。 以及透過這些Project Template所開 發出來的應用程式展示範例。
下載WAT for Windows Phone 位於http: //watwp. codeplex. com/
安裝WAT for Windows Phone 執行WATWindows. Phone. exe 完成後會看到(C: Windows. AzureWATWindows. Phone)
安裝WAT for Windows Phone 出現安裝畫面
Let's Do It…
建立blob帳號與Container
在WP 7中存取blob 使用Windows Azure Toolkit for WP 7 使用Windows. Phone. Cloud. Storage. Client 位於C: Windows. AzureWATWindows. PhoneBinaries //建立credentials Storage. Credentials. Account. And. Key credentials = new Storage. Credentials. Account. And. Key( Storage. Account, Storage. Key); 這邊提供Storage帳號與Key //建立Cloud. Blob. Client = new Cloud. Blob. Client(Blob. Endpoint, credentials);
在WP 7中存取blob 這邊提供Container. Name //決定要連結的Container var mycontainer = Blob. Client. Get. Container. Reference(Container. Name); string file. Name = System. Date. Time. Now. To. String("yyyy. MMdd-HHmmss") + ". bmp"; var blob = mycontainer. Get. Blob. Reference(file. Name); //進行上傳動作 blob. Upload. From. Stream(fs, (ret) => { //顯示結果訊息 透過API以非同步方式上傳 });
Demo:在WP 7中存取blob ü 使用WAT套件 ü 建立blob Container ü 在WP 7中存取blob(上傳照片) 董大偉 David@a. Rock. com. tw 光岩資訊 技術總監 台灣微軟MSDN講座講師 WP 7 Access. Blob. Test WP 7直接存取blob. wmv
Demo 在WP 7中存取blob
在WP 7中存取blob(with SAS) Shared Access Signature 時間戳章、存取設定 http: //forwp 7 test 20120917. blob. core. windows. net/contain er 1/1336920569_Bible. png? sr=c&si=Policy. Key&sig=su. AZ n. Vb 40 JKR 8 X 8 Rfz. Dm. XVCVZq. QRuw. Ta. Tus 44 rkfik 0%3 D 建立類似上面這樣的Signature, 以限制存取時間和權限
Demo 在WP 7中存取blob(with SAS)
Ø Single Sign On身分整合驗證
Demo:使用專案範本 ü 建立Windows Phone Cloud Application ü 存取blob、Table ü 使用Push Notification 董大偉 David@a. Rock. com. tw 光岩資訊 技術總監 台灣微軟MSDN講座講師 WAT Project Template. wmv
Demo 在WP 7中存取blob、Table 使用Push Notification
關於Azure ACS Single Sign On
Demo:使用專案範本 ü 建立Windows Phone Cloud Application ü 建立App. Fabric , 建立Name. Space ü 使用Windows Azure ACS 董大偉 David@a. Rock. com. tw 光岩資訊 技術總監 台灣微軟MSDN講座講師 WAT Project Template - 2. ACS. wmv 身分驗證
Demo 使用Windows Azure ACS
關於 關於Azure Mobile Service
public class Todo. Item { public int id { get; set; } [System. Runtime. Serialization. Data. Member()] public string text { get; set; } [System. Runtime. Serialization. Data. Member()] public bool complete { get; set; } } 注意id欄位是必須的
位於 public static object Json. To. Obj(string json, Type. System. Runtime. Serializatio type) { n try { object obj; Memory. Stream ms = new Memory. Stream(Encoding. UTF 8. Get. Bytes(json)); Data. Contract. Json. Serializer ser = new Data. Contract. Json. Serializer(type); obj = ser. Read. Object(ms); ms. Close(); return obj; } catch (Exception ex) { Message. Box. Show(ex. Message + " JSON: " + json); return null; } }
public static string Object. To. Json(object obj, Type type) { try { //Create a stream to serialize the object to. Memory. Stream ms = new Memory. Stream(); // Serializer the User object to the stream. Data. Contract. Json. Serializer ser = new Data. Contract. Json. Serializer(type); ser. Write. Object(ms, obj); byte[] json = ms. To. Array(); ms. Close(); return Encoding. UTF 8. Get. String(json, 0, json. Length); } catch (Exception ex) { Message. Box. Show(ex. Message); return string. Empty; } }
使用Web. Client呼叫REST API //Update Web. Client wc = new Web. Client(); wc. Headers["Content-Type"] = "application/x-www-form-urlencoded"; wc. Headers["X-ZUMO-APPLICATION"] = key; wc. Upload. String. Completed += (ss, arg) => { 記得要給Key if (arg. Error == null) { a. Rock. Phone. Dialog. Notify. Dialog. Show. Toast. Message("OK"); refresh(); } else { Message. Box. Show(arg. Error. Message); } }; wc. Upload. String. Async( new Uri("https: //David. Test. azure-mobile. net/tables/Todo. Item/" + item. id), "PATCH", Json. Helper. Object. To. Json(item, typeof(Todo. Item))); 透過Data. Contract. Json. Serializer處理序列 化
Demo:使用Windows Azure Mobile Service ü ü ü 建立SQL Azure Server & Database 建立Mobile Service, 建立資料表 透過Azure Portal維護資料表 建立WP 7用戶端 使用REST API+JSON Parsing 進行資料CRUD 董大偉 David@a. Rock. com. tw 光岩資訊 技術總監 台灣微軟MSDN講座講師 Using. Mobile. Servies. Via. WP 7 Mobile. Service. Test
Demo 在WP 7使用Windows Azure Mobile Service
關於 Windows Phone開發的未來
關於 Porting to Windows Store App
15: 10 ~ 16: 20
免費 !! Windows Store / Windows Azure / Windows Phone http: //aka. ms/startmsdn 每月固定 12個月
Q&A
Resources Connect. Share. Discusss http: //www. microsoft. com/taiwan/techdays 2012/ Microsoft Certification & Training Resources http: //www. microsoft. com/learning/zh/tw/ Resources for IT Professionals http: //social. technet. microsoft. com/Forums/zhtw/categories/ Resources for Developers http: //social. msdn. microsoft. com/Forums/zhtw/categories/
- Slides: 67