SlideShare ist ein Scribd-Unternehmen logo
1 von 52
Downloaden Sie, um offline zu lesen
Introducing Cloud Architecture
• The Cloud Architecture
• IaaS
• PaaS
• Next Generation Cloud Service Architecture
• 架構於現有的PaaS/IaaS基礎上
• 將多種服務整合成單一服務
• 提供直覺且簡單的服務管理介面
• 是針對特定型別的應用程式而設計的服務
Windows Azure Mobile Services (WAMS)
• 架構於現有的PaaS上
• 將數種服務整合成單一服務
• 資料儲存: SQL Database Services
• 使用者驗證: Authentication Services
• 訊息推播: Push Notification Services
• 為
• 行動平台的App 開發而設計
• 提供
• 直覺的管理介面
• 具高延展性, 可因應未來使用者增加的情況
連線型行動平台App的架構
Accessing data
authentication
Call web service
如果… 要開發一個雲端待辦事項的應用程式..
• 使用者驗證
• 您需要儲存使用者的資料
• 您需要一個伺服器提供驗證的Web Service
• 儲存待辦事項的資料
• 您需要一個伺服器來儲存這些資料
• 當伺服器移除過期的資料時, 使用者必須收到通知
• 您需要一個在背景執行, 且定時刪除過期資料的程式
• 因此
• 您需要一個Web Server
• 提供使用者驗證
• 執行定期執行移除過期資料的程式
• 提供Web Service供行動裝置呼叫
• 您需要一個資料庫伺服器
• 儲存使用者資料
• 您需要寫網頁程式來提供服務
• ASP.NET
• PHP
• …..
一言以蔽之,要很多伺服器
程式部分可能會是 ………..
這還只是網頁或是Web Service程式而
已…..
我們還沒開始談App的開發
也沒談到安全性的問題…….
如果使用Windows Azure Mobile Service
• 提供SQL Database Service
• 可以儲存資料
• 提供背景排程服務
• 您可以撰寫程式來定期移除過期資料
• 發送推播通知
• 提供整合性的使用者驗證
• 您可以透過Facebook, Microsoft Account, Google Account或 Twitter來驗證使用者
• 您可以由這些驗證服務提供者取得使用者資料
• 因此
• 您不需要準備一個Web Server
• 您不需要準備一個Database Server
• 您不需要撰寫驗證使用者的程式
• 您不需要寫太多的程式就可以完成訊息推播
• 只要
• 申請一個Windows Azure帳戶
• 建立一個Mobile Service
• 設定資料庫及驗證方式
• 下載平台(WP,Android,iOS)需要的函式庫
• 寫很少量的程式碼(Node.js)
• 接著只要專注於您的App開發就好了
有了WAMS, 您只需要…..
讓我們開始吧
建立 Windows Azure Mobile Service
DEMO
建立資料表
關於權限
Can use by any user
Need application key
Authenticated users
Internal use only
設定整合驗證 – Google Account
• 您可以透過 Facebook, Microsoft Account, Google Account 或
Twitter來驗證使用者
關於Google Account
• 您必須設定 Authorized Redirect URIs 與
Authorized JavaScript Origins 兩個欄位
設定透過Google Account進行整合驗證
這就是一個雲端待辦事項App所需要的
Server Side 工作
我們可以開始寫App了, 有沒有很歡樂?
建立 Windows Phone 應用程式
• 透過NuGet Package Manager 加入 WAMS
Client Library's
取得存取Azure Mobile Services所需要的
Application Key
存取 Mobile Service
public partial class App : Application
{
internal static MobileServiceClient MobileService =
new MobileServiceClient("https://todo64.azure-mobile.net/",
"xisXQCpUGwQfwOwUqvxcqwkVhtdiLR72");
• 建立MobileServiceClient物件
資料表與類別的對應
using Microsoft.WindowsAzure.MobileServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TodoApplication
{
[DataTable("todos")]
public class TodoDataModel
{
public int Id { get; set; }
public string Description { get; set; }
public bool Complete { get; set; }
}
}
• Windows Azure Mobile Services 會自動依據您定義的類別
來建立資料表結構
添加處理使用者驗證的程式碼
public partial class MainPage : PhoneApplicationPage
{
private MobileServiceUser user;
private async System.Threading.Tasks.Task Authenticate()
{
while (user == null)
{
try
{
user = await App.MobileService.LoginAsync(MobileServiceAuthenticationProvider.Google);
}
catch (InvalidOperationException)
{
Dispatcher.BeginInvoke(() =>
{
MessageBox.Show("You must log in. Login Required");
});
}
}
}
private async void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
await Authenticate();
}
如何取得使用者資訊?
• 當使用者登入後
• 您可以由驗證提供者端(Facebook, Microsoft Account,
Google Account , Twitter)取得使用者資訊
• 您可以取得一個唯一的使用者編號 (由WAMS提供)
• 但
• 除了由WAMS提供的使用者編號外, 其餘要由驗證提
供者端取得的資訊, 無法透過Client Library‘s直接取得
• 如果需要, 您可以
• 撰寫Server-Side Script來取得
• 或是撰寫Custom API回傳給客戶端
Table Triggers
• 開發者可以自訂CRUD 的個別行為
• 以Node.js語法撰寫, 未來會提供.NET Language(像是C#
等等)
Storing User ID
• 我們需要分辨待辦項目是屬於哪個使用者的
• 因此必須自訂Insert的行為, 新增時存入使用者ID
• 順便儲存建立此項目的日期
• createDate, userId 並未定義於先前的對應類別
• WAMS會自動添加這些欄位, 而客戶端可以不知道這些欄
位的存在
UI的設計與資料的取得
• 此時並沒有任何資料, 所以先測試增加一筆資料, 方便後
面的UI設計
• 取得資料表物件
• 新增資料
Test And Run
Designing UI and Get data
Todo Item record
ListBox
取得資料
• 這行程式會回傳所有資料
• 通常, 我們只希望回傳該使用者的資料
• 透過自訂Read 可以達到這個需求
實作 CUD
• 更新資料
• 刪除資料
• 查詢資料
以Custom API實作查詢
• 雖然直接由客戶端進行查詢很酷
• 但
• 在WAMS中, 有更具效率的做法
以Custom API實作查詢
客戶端呼叫API的程式碼
背景排程執行的工作及Push Notification
• 建立 channels 資料表
• 大多數的 push notification services (WP, iOS,
Android) 都是基於channel的觀念
• Push Notification Services會分配一個ID給裝置
• 因此我們需要一個可以儲存push uri的資料表
建立 新增 channel 資料的API
建立排程
定時執行的Script
Test And Run
Demo
需要用到更多的SQL Server功能嗎?
Android Version
您需要什麼?
• 下載client library's for android
• http://go.microsoft.com/fwlink/p/?linkid=28
0126&clcid=0x409
• 將所有檔案放到android project中 (libs/)
撰寫程式
• 建立 mobile service client 物件
• 設計UI
_client = new MobileServiceClient("https://todo64.azure-mobile.net/",
"WGoPUayxXeaWRsOiHrzGfcotvffFfM31", this);
回傳資料
_table.execute(new TableQueryCallback<Todo>() {
@Override
public void onCompleted(List<Todo> result, int count,
Exception exception, ServiceFilterResponse response) {
if(exception == null){
_adapter.clear();
for (Todo item : result) {
_adapter.add(item);
}
}
}
});
實作CUD
• 新增
• 刪除
• 修改
_table.insert(item, new TableOperationCallback<Todo>());
_table.delete(item, new TableOperationCallback<Todo>());
_table.update(item, new TableOperationCallback<Todo>());
Integrate Google Cloud Message
• 下載 Google Cloud Message Library
• 目前已併到Google Play Services API中
呼叫CUSTOM API
ArrayList<Pair<String, String>> parameters = new ArrayList<Pair<String, String>>();
parameters.add(new Pair<String, String>("device", "android"));
parameters.add(new Pair<String, String>("uri", regID));
_client.invokeApi("addchannel", "POST", parameters,
new ApiJsonOperationCallback()
{
@Override
public void onCompleted(JsonElement jsonObject,
Exception exception, ServiceFilterResponse response) {
int i = 0;
i = i++;
}
});
Test And Run
Demo
IOS
What’s you need?
• 下載Client Library's
• https://go.microsoft.com/fwLink/p/?LinkID=26
6533
• 解開後將兩個目錄複製到iOS Project中
撰寫程式
• 建立 mobile service client 物件
• 設計UI
//in .h
@property (nonatomic, strong) MSClient *client;
// in .m
self.client = [MSClient clientWithApplicationURLString:@"https://todo64.azure-
mobile.net/" applicationKey:@"<app key><your key="">"];
回傳資料
self.table = [self.client tableWithName:@todos"];
NSPredicate * predicate = [NSPredicate predicateWithFormat:@“Complete == NO"];
[self.table readWithPredicate:predicate completion:^(NSArray *results,
NSInteger totalCount, NSError *error)
{
self.items = [results mutableCopy];
[self.tableView reloadData];
}];
Implement CUD Operations
• 新增、修改、刪除等動作則是透過MSTable的
insert、update、delete函式,跟Windows Phone、
Android不同的是iOS並沒有所謂的Customers類別,
而是用NSDictionary來呈現資料列。
NSDictionary *item = @{ @”Description" : “buy computer” };
參考資料
• Windows Azure Mobile Document
• http://www.windowsazure.com/en-
us/develop/mobile/reference/
• My Blog
• http://www.dotblogs.com.tw/code6421
• Windows Azure Mobile Service SDK for Windows
Phone 7
• https://github.com/zaxy78/azure-mobile-wp7-
sdk
• (unofficial)

Weitere ähnliche Inhalte

Was ist angesagt?

Teched 2012 60分钟构建私有云
Teched 2012 60分钟构建私有云Teched 2012 60分钟构建私有云
Teched 2012 60分钟构建私有云Cheng Zhang
 
Getting Started with Serverless Architecture - 深入淺出無伺服器架構應用程式
Getting Started with Serverless Architecture - 深入淺出無伺服器架構應用程式Getting Started with Serverless Architecture - 深入淺出無伺服器架構應用程式
Getting Started with Serverless Architecture - 深入淺出無伺服器架構應用程式Amazon Web Services
 
王涛:基于Cloudera impala的非关系型数据库sql执行引擎
王涛:基于Cloudera impala的非关系型数据库sql执行引擎王涛:基于Cloudera impala的非关系型数据库sql执行引擎
王涛:基于Cloudera impala的非关系型数据库sql执行引擎hdhappy001
 
Azure Container Registry(preview)x Web App On Linux(preview)
Azure Container Registry(preview)x Web App On Linux(preview)Azure Container Registry(preview)x Web App On Linux(preview)
Azure Container Registry(preview)x Web App On Linux(preview)Ch Rick
 
Team Foundation Server
Team Foundation ServerTeam Foundation Server
Team Foundation Server國昭 張
 
Cloud computing for manufacturing
Cloud computing for manufacturingCloud computing for manufacturing
Cloud computing for manufacturingJeff Chu
 
一步一步开发Html5 mobile apps
一步一步开发Html5 mobile apps一步一步开发Html5 mobile apps
一步一步开发Html5 mobile appsAdam Lu
 
AWS_Educate_Team_SCU_Volunteer_Training_0909
AWS_Educate_Team_SCU_Volunteer_Training_0909AWS_Educate_Team_SCU_Volunteer_Training_0909
AWS_Educate_Team_SCU_Volunteer_Training_0909土撥 JIE
 

Was ist angesagt? (8)

Teched 2012 60分钟构建私有云
Teched 2012 60分钟构建私有云Teched 2012 60分钟构建私有云
Teched 2012 60分钟构建私有云
 
Getting Started with Serverless Architecture - 深入淺出無伺服器架構應用程式
Getting Started with Serverless Architecture - 深入淺出無伺服器架構應用程式Getting Started with Serverless Architecture - 深入淺出無伺服器架構應用程式
Getting Started with Serverless Architecture - 深入淺出無伺服器架構應用程式
 
王涛:基于Cloudera impala的非关系型数据库sql执行引擎
王涛:基于Cloudera impala的非关系型数据库sql执行引擎王涛:基于Cloudera impala的非关系型数据库sql执行引擎
王涛:基于Cloudera impala的非关系型数据库sql执行引擎
 
Azure Container Registry(preview)x Web App On Linux(preview)
Azure Container Registry(preview)x Web App On Linux(preview)Azure Container Registry(preview)x Web App On Linux(preview)
Azure Container Registry(preview)x Web App On Linux(preview)
 
Team Foundation Server
Team Foundation ServerTeam Foundation Server
Team Foundation Server
 
Cloud computing for manufacturing
Cloud computing for manufacturingCloud computing for manufacturing
Cloud computing for manufacturing
 
一步一步开发Html5 mobile apps
一步一步开发Html5 mobile apps一步一步开发Html5 mobile apps
一步一步开发Html5 mobile apps
 
AWS_Educate_Team_SCU_Volunteer_Training_0909
AWS_Educate_Team_SCU_Volunteer_Training_0909AWS_Educate_Team_SCU_Volunteer_Training_0909
AWS_Educate_Team_SCU_Volunteer_Training_0909
 

Andere mochten auch

KSDG 4th event: Windows Azure Session
KSDG 4th event: Windows Azure SessionKSDG 4th event: Windows Azure Session
KSDG 4th event: Windows Azure SessionJeff Chu
 
Flying on the Cloud: Designing and Architecting Cloud Application on Windows ...
Flying on the Cloud: Designing and Architecting Cloud Application on Windows ...Flying on the Cloud: Designing and Architecting Cloud Application on Windows ...
Flying on the Cloud: Designing and Architecting Cloud Application on Windows ...Jeff Chu
 
微軟實戰課程日:玩轉雲端 技術與架構
微軟實戰課程日:玩轉雲端 技術與架構微軟實戰課程日:玩轉雲端 技術與架構
微軟實戰課程日:玩轉雲端 技術與架構Jeff Chu
 
Mobile services (Tech Days 2013)
Mobile services (Tech Days 2013)Mobile services (Tech Days 2013)
Mobile services (Tech Days 2013)Jeffray Huang
 
Tech.days Taiwan AZR305
Tech.days Taiwan AZR305 Tech.days Taiwan AZR305
Tech.days Taiwan AZR305 Jeff Chu
 
Python conf 2013 taiwan azure
Python conf 2013 taiwan azurePython conf 2013 taiwan azure
Python conf 2013 taiwan azureJeff Chu
 

Andere mochten auch (7)

KSDG 4th event: Windows Azure Session
KSDG 4th event: Windows Azure SessionKSDG 4th event: Windows Azure Session
KSDG 4th event: Windows Azure Session
 
Flying on the Cloud: Designing and Architecting Cloud Application on Windows ...
Flying on the Cloud: Designing and Architecting Cloud Application on Windows ...Flying on the Cloud: Designing and Architecting Cloud Application on Windows ...
Flying on the Cloud: Designing and Architecting Cloud Application on Windows ...
 
微軟實戰課程日:玩轉雲端 技術與架構
微軟實戰課程日:玩轉雲端 技術與架構微軟實戰課程日:玩轉雲端 技術與架構
微軟實戰課程日:玩轉雲端 技術與架構
 
Mobile services (Tech Days 2013)
Mobile services (Tech Days 2013)Mobile services (Tech Days 2013)
Mobile services (Tech Days 2013)
 
Tech.days Taiwan AZR305
Tech.days Taiwan AZR305 Tech.days Taiwan AZR305
Tech.days Taiwan AZR305
 
Python conf 2013 taiwan azure
Python conf 2013 taiwan azurePython conf 2013 taiwan azure
Python conf 2013 taiwan azure
 
Mobile Web 2.0
Mobile Web 2.0Mobile Web 2.0
Mobile Web 2.0
 

Ähnlich wie Windows Azure Developer Day - WAMS

Windows Azure Virtual Machine Services for Developers
Windows Azure Virtual Machine Services for DevelopersWindows Azure Virtual Machine Services for Developers
Windows Azure Virtual Machine Services for DevelopersJeff Chu
 
深入浅出 V cloud director
深入浅出 V cloud director深入浅出 V cloud director
深入浅出 V cloud directorITband
 
深入淺出 AWS 大數據工具
深入淺出 AWS 大數據工具深入淺出 AWS 大數據工具
深入淺出 AWS 大數據工具Amazon Web Services
 
移动后端开发的精益之道
移动后端开发的精益之道移动后端开发的精益之道
移动后端开发的精益之道wenny yuan
 
Windows Phone 7 in azure
Windows Phone 7 in azureWindows Phone 7 in azure
Windows Phone 7 in azureTao Wang
 
今日如何建立一个安全的私有云
今日如何建立一个安全的私有云今日如何建立一个安全的私有云
今日如何建立一个安全的私有云ITband
 
微服務架構 導入經驗分享 吳剛志 - Community Open Camp
微服務架構 導入經驗分享 吳剛志 - Community Open Camp微服務架構 導入經驗分享 吳剛志 - Community Open Camp
微服務架構 導入經驗分享 吳剛志 - Community Open CampAndrew Wu
 
云计算与开源 刘黎明 世纪互联
云计算与开源  刘黎明  世纪互联云计算与开源  刘黎明  世纪互联
云计算与开源 刘黎明 世纪互联Liming Liu
 
AWS 雲端環境的資安佈局.pdf
AWS 雲端環境的資安佈局.pdfAWS 雲端環境的資安佈局.pdf
AWS 雲端環境的資安佈局.pdfssuser293781
 
数据架构方面的一些探讨
数据架构方面的一些探讨数据架构方面的一些探讨
数据架构方面的一些探讨Chao Zhu
 
ASP.Net MVC Framework
ASP.Net MVC FrameworkASP.Net MVC Framework
ASP.Net MVC Framework國昭 張
 
[2020 .NET Conf] 企業Azure DevOps Service 實際應用架構與秘辛
[2020 .NET Conf] 企業Azure DevOps Service 實際應用架構與秘辛[2020 .NET Conf] 企業Azure DevOps Service 實際應用架構與秘辛
[2020 .NET Conf] 企業Azure DevOps Service 實際應用架構與秘辛Edward Kuo
 
如何使用Azure mobile service
如何使用Azure mobile service如何使用Azure mobile service
如何使用Azure mobile servicePou Mason
 
雲端環境的快取策略-Global Azure Bootcamp 2015 臺北場
雲端環境的快取策略-Global Azure Bootcamp 2015 臺北場雲端環境的快取策略-Global Azure Bootcamp 2015 臺北場
雲端環境的快取策略-Global Azure Bootcamp 2015 臺北場twMVC
 
新浪微博平台与安全架构
新浪微博平台与安全架构新浪微博平台与安全架构
新浪微博平台与安全架构n716
 
合久必分,分久必合
合久必分,分久必合合久必分,分久必合
合久必分,分久必合Qiangning Hong
 
Big Data Technology - Cloud Computing
Big Data Technology - Cloud ComputingBig Data Technology - Cloud Computing
Big Data Technology - Cloud ComputingRen-Hao (PAN) Pan
 
基于AWS Lambda的无服务器架构在Strikingly中的应用
基于AWS Lambda的无服务器架构在Strikingly中的应用基于AWS Lambda的无服务器架构在Strikingly中的应用
基于AWS Lambda的无服务器架构在Strikingly中的应用Daniel Gong
 
深入研究雲端應用程式平台-AppFabric
深入研究雲端應用程式平台-AppFabric深入研究雲端應用程式平台-AppFabric
深入研究雲端應用程式平台-AppFabricJohn Chang
 
0527 asus cloud day 開放。引領數位內容進軍國際 – 華碩雲端市集
0527 asus cloud day 開放。引領數位內容進軍國際 – 華碩雲端市集0527 asus cloud day 開放。引領數位內容進軍國際 – 華碩雲端市集
0527 asus cloud day 開放。引領數位內容進軍國際 – 華碩雲端市集ASUSCloud
 

Ähnlich wie Windows Azure Developer Day - WAMS (20)

Windows Azure Virtual Machine Services for Developers
Windows Azure Virtual Machine Services for DevelopersWindows Azure Virtual Machine Services for Developers
Windows Azure Virtual Machine Services for Developers
 
深入浅出 V cloud director
深入浅出 V cloud director深入浅出 V cloud director
深入浅出 V cloud director
 
深入淺出 AWS 大數據工具
深入淺出 AWS 大數據工具深入淺出 AWS 大數據工具
深入淺出 AWS 大數據工具
 
移动后端开发的精益之道
移动后端开发的精益之道移动后端开发的精益之道
移动后端开发的精益之道
 
Windows Phone 7 in azure
Windows Phone 7 in azureWindows Phone 7 in azure
Windows Phone 7 in azure
 
今日如何建立一个安全的私有云
今日如何建立一个安全的私有云今日如何建立一个安全的私有云
今日如何建立一个安全的私有云
 
微服務架構 導入經驗分享 吳剛志 - Community Open Camp
微服務架構 導入經驗分享 吳剛志 - Community Open Camp微服務架構 導入經驗分享 吳剛志 - Community Open Camp
微服務架構 導入經驗分享 吳剛志 - Community Open Camp
 
云计算与开源 刘黎明 世纪互联
云计算与开源  刘黎明  世纪互联云计算与开源  刘黎明  世纪互联
云计算与开源 刘黎明 世纪互联
 
AWS 雲端環境的資安佈局.pdf
AWS 雲端環境的資安佈局.pdfAWS 雲端環境的資安佈局.pdf
AWS 雲端環境的資安佈局.pdf
 
数据架构方面的一些探讨
数据架构方面的一些探讨数据架构方面的一些探讨
数据架构方面的一些探讨
 
ASP.Net MVC Framework
ASP.Net MVC FrameworkASP.Net MVC Framework
ASP.Net MVC Framework
 
[2020 .NET Conf] 企業Azure DevOps Service 實際應用架構與秘辛
[2020 .NET Conf] 企業Azure DevOps Service 實際應用架構與秘辛[2020 .NET Conf] 企業Azure DevOps Service 實際應用架構與秘辛
[2020 .NET Conf] 企業Azure DevOps Service 實際應用架構與秘辛
 
如何使用Azure mobile service
如何使用Azure mobile service如何使用Azure mobile service
如何使用Azure mobile service
 
雲端環境的快取策略-Global Azure Bootcamp 2015 臺北場
雲端環境的快取策略-Global Azure Bootcamp 2015 臺北場雲端環境的快取策略-Global Azure Bootcamp 2015 臺北場
雲端環境的快取策略-Global Azure Bootcamp 2015 臺北場
 
新浪微博平台与安全架构
新浪微博平台与安全架构新浪微博平台与安全架构
新浪微博平台与安全架构
 
合久必分,分久必合
合久必分,分久必合合久必分,分久必合
合久必分,分久必合
 
Big Data Technology - Cloud Computing
Big Data Technology - Cloud ComputingBig Data Technology - Cloud Computing
Big Data Technology - Cloud Computing
 
基于AWS Lambda的无服务器架构在Strikingly中的应用
基于AWS Lambda的无服务器架构在Strikingly中的应用基于AWS Lambda的无服务器架构在Strikingly中的应用
基于AWS Lambda的无服务器架构在Strikingly中的应用
 
深入研究雲端應用程式平台-AppFabric
深入研究雲端應用程式平台-AppFabric深入研究雲端應用程式平台-AppFabric
深入研究雲端應用程式平台-AppFabric
 
0527 asus cloud day 開放。引領數位內容進軍國際 – 華碩雲端市集
0527 asus cloud day 開放。引領數位內容進軍國際 – 華碩雲端市集0527 asus cloud day 開放。引領數位內容進軍國際 – 華碩雲端市集
0527 asus cloud day 開放。引領數位內容進軍國際 – 華碩雲端市集
 

Windows Azure Developer Day - WAMS