Windows Azure Mobile Services を使った  
 Android/iOS アプリケーションの構築


佐藤直⽣生  @satonaoki                 鈴鈴⽊木  章太郎郎  @shosuz
Windows  Azure  テクニカルエバンジェリスト     テクニカルエバンジェリスト  兼  MTC  アーキテクト
http://satonaoki.wordpress.com/   http://blogs.msdn.com/b/shosuz
⽇日本マイクロソフト株式会社                    ⽇日本マイクロソフト株式会社
Windows Azure とは
ミ
アプリケーション                                                                                                                             ド
                                                                                                                                     ル
                                                                                                                                     ウ
ネットワーク                Traffic Manager                            Connect                             Virtual Network                 ア
                          (Public Preview)                    (Public Preview)                        (Public Preview)



キャッシュ                                 認証                                                システム連携                                      Media
                                                                    AD                                                             Services

        占有型                                                       Azure
                    共有型
 CDN   キャッシュ                                                 Active Directory                                   キュー
                   キャッシュ                 アクセス制御
       (Preview)                                                (Preview)                サービス  バス


                                               RDB                                                                                   HPC
データ
                   Blob         Table
                                               関連        レポート
                                                                            Datasync
                                                                            (Preview)
                                                                                             Import/Export
                                                                                                                 PIT Restore
                                                                                                               (Limited Preview)
        RDB

                                                                                                                                   Hadoop

ホスティング
                                                                                                                                   Service
                                                                                                                                   (Preview)
                                                    Virtual Machines                Websites            Mobile Services
                            Cloud Services           (Public Preview)             (Public Preview)       (Public Preview)


                                             Windows Azure                                              ファブリック
管理理                                          管理理ポータル                                                    コントローラ
Windows Azure
Mobile Services とは
http://www.windowsazure.com/mobile   Windows 8、iOS、Windows Phone 8、Android

                                     データ
Github
https://github.com/WindowsAzure/
azure-mobile-services


Get started with Mobile
Services for Android
http://www.windowsazure.com/en-us/
develop/mobile/tutorials/get-started-
android/
Github
https://github.com/WindowsAzure/azure-mobile-
services


Get started with Mobile
Services for iOS
http://www.windowsazure.com/en-us/develop/mobile/
tutorials/get-started-ios/
SQL  サーバーの利利⽤用と
サーバーロジックの開発
http://msdn.microsoft.com/en-us/library/windowsazure/jj554226.aspx
プッシュ通知機能の開発
Windows 8



            (2)

                  (3)
     (1)



            (3)
認証連携機能の開発
Live Connect ポータル
                   https://manage.dev.live.com/Applications/
                   Index  




  アプリケーション キーを持つ
  ユーザー(デフォルト値)
まとめ
Windows 8、iOS、Windows Phone 8、Android

データ
Appendix
・データアクセス、プッシュ通知、認証サポート
  Windows 8、Windows Phone 8 SDK、iOS SDK SDK、Android
SDK

・強⼒力力なサーバーサイドスクリプトのサポート
  プッシュ通知、バリデーション、プリプロセッシング、
  ポストプロセッシング、他の  Web サービスとの連携
JSON 値          T-SQL 型
数値 (整数、10 進数、   Float(53)
浮動⼩小数点数)
ブール値            Bit
DateTime        DateTimeOffset(3)
⽂文字列列           Nvarchar(max)
https://dev.twitter.com/
                                        https://dev.twitter.com/apps/new




Register your apps for Twitter login with Mobile Services
http://www.windowsazure.com/en-us/develop/mobile/how-to-guides/register-for-twitter-authentication/
複雑なフィルタリングの例例

Supported Modules + Globals
function  read(query,	
  user,	
  request)	
  {
        query.where(function	
  (userId)	
  {
                   mssql
                return	
  this.UserId	
  ==	
  userId;
        },	
  user.userId);
                   request
        request.execute();
}	
  
                   console
function	
  read(query,	
  user,	
  request)	
  {

                
                   push
        query.where(function	
  (userId)	
  {
                 return	
  this.UserId	
  ==	
  userId	
  &&
                   tables
                            (this.Category	
  ==	
  "Fiction"	
  ||	
  this.Category	
  ==	
  "Action")	
  &&
                              this.Rating	
  >	
  2;
        },	
  user.userId);
                   statusCodes
        request.execute();
 }	
  
 …
Windows 8/Phone 8
var table =

                                               iOS
         MobileService.GetTable <Apartment>;
var Apartments = await table
  .where(a => a.Bedrooms > 2)
  .ToListAsync();                              table = [client getTable : @”apartment”];
                                               NSPredicate* pred = [NSPredicate
                                                   predicateWithFormat:@”bedrooms > 2”];

Android (例例)                                   [tableReadWhere : pred
                                                   completion : ^(NSArray* results,
MobileTable <Apartment> table =                                    NSInteger count,
   service.gettable(Apartment.class);                              Nerror* err) {
List<Apartment> apartments =                        //…
   table.where()                               }];
        .gt(“bedrooms”, 2)
        .select();
push.wns



           push.mpns
Live Connect ポータル
                                               https://manage.dev.live.com/Applications/
                                               Index  




http://msdn.microsoft.com/ja-JP/windows/apps
Windows  ストアアプリポータル
Windows 8
CurrentChannel = await PushNotificationChannelManager
                        .CreatePushNotificationChannelForApplicaionAsync();
Windows Phone 8
CurrentChannel = new HttpNotificationCannel(“ApartmentPushChannel”);
CurrentChannel.Open();
CurrentChannel.BindToShellToast();

Server Side Script
mpns.sendToast(channel.uri, “New Apartment Added”, apartment.address);
wns.sendToat02(channel.uri,
  {text01 : “New Apartment Added”, text02 : apartment.address, });
Visual Studio では  Intellisense  で  Identity Provider  を選択可能
Windows 8 / Windows Phone 8
If (MobileService.CurrentUser == null) {
    var user = await MobileSevice.LoginAsync (
                      MobileServiceAuthenticationProvider.Twitter);


iOS
If (client.currentUser == nil) {
    [client loginViewControllerWithProvider : @”twitter”
              completion : ^(MSUser* user, NSError* err) {
         //…
    }];
}
http://blogs.msdn.com/b/shosuz/archive/2013/01/03/sendgrid-windows-azure-
mobile-services.aspx
診断   拡張 –
     コンピューティング

ログ   拡張 - ストレージ
10  モバイル  
 サービス                      1  GB  SQL




                                        WA  の無料料評価版
                          データベース




  プレビュー期間中は  SLA  なし。S  インスタンスのみ使⽤用可能。プレビュー期間中は、通常の従
  量量課⾦金金料料⾦金金から  33%  割引で予約済みインスタンスにアップグレード可能。
$
共有インスタンス      予約済みインスタンス
(マルチテナント環境)   (プライベート VM)
S インスタンスのみが   S インスタンスのみが
使⽤用可能なサイズ。    使⽤用可能なサイズ。     99.9%
複数購⼊入が可能      複数購⼊入が可能
パブリック プレビュー   プレビューの料料⾦金金は
公開時は無料料       Web サイトと同じ
              割引料料⾦金金になる
Resources
Mobile Services Developer Portal




http://www.windowsazure.com/mobile   34
Event Buddy(iOS)



Tic Tac Toe Leaderboard  
(iOS/Android)


Feedback (iOS/Android)
MiniBlog
http://msdn.microsoft.com/ja-jp/
windowsazure/hh697503
http://blogs.msdn.com/b/shosuz/archive/2013/01/11/windows-‐‑‒azure-‐‑‒new-‐‑‒code-‐‑‒samples-‐‑‒and-‐‑‒
tutorials.aspx                                                                                            37

Windows Azure Mobile Services を使った Android/iOS アプリケーションの構築

  • 1.
    Windows Azure MobileServices を使った   Android/iOS アプリケーションの構築 佐藤直⽣生  @satonaoki   鈴鈴⽊木  章太郎郎  @shosuz Windows  Azure  テクニカルエバンジェリスト テクニカルエバンジェリスト  兼  MTC  アーキテクト http://satonaoki.wordpress.com/ http://blogs.msdn.com/b/shosuz ⽇日本マイクロソフト株式会社 ⽇日本マイクロソフト株式会社
  • 3.
  • 4.
    ミ アプリケーション ド ル ウ ネットワーク Traffic Manager Connect Virtual Network ア (Public Preview) (Public Preview) (Public Preview) キャッシュ 認証 システム連携 Media AD Services 占有型 Azure 共有型 CDN キャッシュ Active Directory キュー キャッシュ アクセス制御 (Preview) (Preview) サービス  バス RDB HPC データ Blob Table 関連 レポート Datasync (Preview) Import/Export PIT Restore (Limited Preview) RDB Hadoop ホスティング Service (Preview) Virtual Machines Websites Mobile Services Cloud Services (Public Preview) (Public Preview) (Public Preview) Windows Azure ファブリック 管理理 管理理ポータル コントローラ
  • 5.
  • 6.
    http://www.windowsazure.com/mobile Windows 8、iOS、Windows Phone 8、Android データ
  • 7.
    Github https://github.com/WindowsAzure/ azure-mobile-services Get started withMobile Services for Android http://www.windowsazure.com/en-us/ develop/mobile/tutorials/get-started- android/
  • 8.
    Github https://github.com/WindowsAzure/azure-mobile- services Get started withMobile Services for iOS http://www.windowsazure.com/en-us/develop/mobile/ tutorials/get-started-ios/
  • 9.
  • 10.
  • 11.
  • 12.
    Windows 8 (2) (3) (1) (3)
  • 13.
  • 14.
    Live Connect ポータル https://manage.dev.live.com/Applications/ Index   アプリケーション キーを持つ   ユーザー(デフォルト値)
  • 15.
  • 16.
    Windows 8、iOS、Windows Phone8、Android データ
  • 18.
  • 19.
    ・データアクセス、プッシュ通知、認証サポート   Windows 8、Windows Phone8 SDK、iOS SDK SDK、Android SDK ・強⼒力力なサーバーサイドスクリプトのサポート   プッシュ通知、バリデーション、プリプロセッシング、   ポストプロセッシング、他の  Web サービスとの連携
  • 20.
    JSON 値 T-SQL 型 数値 (整数、10 進数、 Float(53) 浮動⼩小数点数) ブール値 Bit DateTime DateTimeOffset(3) ⽂文字列列 Nvarchar(max)
  • 21.
    https://dev.twitter.com/ https://dev.twitter.com/apps/new Register your apps for Twitter login with Mobile Services http://www.windowsazure.com/en-us/develop/mobile/how-to-guides/register-for-twitter-authentication/
  • 22.
    複雑なフィルタリングの例例 Supported Modules +Globals function  read(query,  user,  request)  {        query.where(function  (userId)  { mssql                return  this.UserId  ==  userId;        },  user.userId); request        request.execute(); }   console function  read(query,  user,  request)  {                 push        query.where(function  (userId)  { return  this.UserId  ==  userId  && tables                            (this.Category  ==  "Fiction"  ||  this.Category  ==  "Action")  &&                              this.Rating  >  2;        },  user.userId); statusCodes        request.execute(); }   …
  • 23.
    Windows 8/Phone 8 vartable = iOS MobileService.GetTable <Apartment>; var Apartments = await table .where(a => a.Bedrooms > 2) .ToListAsync(); table = [client getTable : @”apartment”]; NSPredicate* pred = [NSPredicate predicateWithFormat:@”bedrooms > 2”]; Android (例例) [tableReadWhere : pred completion : ^(NSArray* results, MobileTable <Apartment> table = NSInteger count, service.gettable(Apartment.class); Nerror* err) { List<Apartment> apartments = //… table.where() }]; .gt(“bedrooms”, 2) .select();
  • 24.
    push.wns push.mpns
  • 25.
    Live Connect ポータル https://manage.dev.live.com/Applications/ Index   http://msdn.microsoft.com/ja-JP/windows/apps Windows  ストアアプリポータル
  • 26.
    Windows 8 CurrentChannel =await PushNotificationChannelManager .CreatePushNotificationChannelForApplicaionAsync(); Windows Phone 8 CurrentChannel = new HttpNotificationCannel(“ApartmentPushChannel”); CurrentChannel.Open(); CurrentChannel.BindToShellToast(); Server Side Script mpns.sendToast(channel.uri, “New Apartment Added”, apartment.address); wns.sendToat02(channel.uri, {text01 : “New Apartment Added”, text02 : apartment.address, });
  • 27.
    Visual Studio では Intellisense  で  Identity Provider  を選択可能
  • 28.
    Windows 8 /Windows Phone 8 If (MobileService.CurrentUser == null) { var user = await MobileSevice.LoginAsync ( MobileServiceAuthenticationProvider.Twitter); iOS If (client.currentUser == nil) { [client loginViewControllerWithProvider : @”twitter” completion : ^(MSUser* user, NSError* err) { //… }]; }
  • 29.
  • 30.
    診断 拡張 – コンピューティング ログ 拡張 - ストレージ
  • 31.
    10  モバイル   サービス 1  GB  SQL WA  の無料料評価版 データベース プレビュー期間中は  SLA  なし。S  インスタンスのみ使⽤用可能。プレビュー期間中は、通常の従 量量課⾦金金料料⾦金金から  33%  割引で予約済みインスタンスにアップグレード可能。
  • 32.
    $ 共有インスタンス 予約済みインスタンス (マルチテナント環境) (プライベート VM) S インスタンスのみが S インスタンスのみが 使⽤用可能なサイズ。 使⽤用可能なサイズ。 99.9% 複数購⼊入が可能 複数購⼊入が可能 パブリック プレビュー プレビューの料料⾦金金は 公開時は無料料 Web サイトと同じ 割引料料⾦金金になる
  • 33.
  • 34.
    Mobile Services DeveloperPortal http://www.windowsazure.com/mobile 34
  • 35.
    Event Buddy(iOS) Tic TacToe Leaderboard   (iOS/Android) Feedback (iOS/Android)
  • 36.
  • 37.