Microsoft azure mobile services 概要と xamarin との連携
-
Upload
shotaro-suzuki -
Category
Technology
-
view
464 -
download
6
description
Transcript of Microsoft azure mobile services 概要と xamarin との連携
Microsoft Azure Mobile Services 概要と Xamarin との連携
鈴木 章太郎テクニカルエバンジェリスト日本マイクロソフト株式会社デベロッパーエクスペリエンス & エバンジェリズム統括本部http://blogs.msdn.com/b/shosuz/
テクニカルエバンジェリスト http://blogs.msdn.com/b/shosuz
Microsoft Technology Center アーキテクト http://www.microsoft.com/ja-jp/business/mtc/ads.aspx
中央大学 総合政策学部 非常勤講師、 東京工業大学大学院 非常勤講師
経済産業省・ IPA 情報連携用共通語彙基盤 プロジェクト委員
Microsoft 軽音楽部 広報担当( Guitar/Keyboard )
Microsoft Azure Mobile Services 概要ASP.NET Web API バックエンド
オフラインサポートMicrosoft Azure Active Directory 連携
アジェンダ
Mobile Services 概要
MBaaS : Mobile Backend as a Services
データベース
バックエンドの共通化
認証 プッシュ通知
スケール マルチデバイス
モバイルアプリに迅速にクラウドバックエンドを追加
Mobile Services 最新機能を含む全体像
プッシュ通知
データベース
ユーザー認証
バックエンド
Node.js Express
ASP.NET Web API
SQL Table Storage
Blob Storage
WNS & MPNS
APNS GCM
Mongo DB
Notification Hubs
ソース管理
Twitter Microsoft Google Azure Active
Directory
Windows ストアiOSAndroid XamarinPhoneGapSencha
Windows PhoneiOSAndroidHTML 5/JS
クライアントSDK
Hybrid Connections
RE
ST A
PI
はじめての Mobile Services
Xamarin + Node.js バックエンド
Demo
ASP.NET Web API バックエンド
データモデル( EF-CodeFirst )、スケジュールドジョブ Visual Studio のツールを最大限活用 ローカルとリモートでデバッグ、発行
ASP.NET Web API バックエンド
ソースコード
Mobile Services 互換 Web API コントローラー
Git
Web 発行
Commit hook: ビルドプロジェクト
WebsiteXDRIVE\site\wwwroot
Mobile Servicescompatible WebAPIcontrollers
Web.config
C:\...\MobileServices
Mobile Servicesruntime
Web.config
website root
ユーザーDB:EF CodeFirst またはカスタムマイグレーション埋め込まれた App settings
Load
Mobile Services
.NET バックエンドによるCRUD 処理の実装とデバッグ
Demo
Xamarin との連携
Xamarin の特徴
“ フル” ネイティブすべての API が使える
パフォーマンス高コンパイル済パッケージ
C#, .NET , Visual Studio既存資産やスキルを活用
iOS
Android
13
PCL ( Portable Class Library )
ビジネス ロジック C#
Visual Studio with Xamarin
複数の .NET 処理系に対して、バイナリレベルで再利用できるライブラリネイティブ
14
PCL の仕組み
ユーザインターフェース機能の具体化依存コード
ユーザインターフェース機能の具体化依存コード
ユーザインターフェース機能の具体化依存コード
ロジック・データ・抽象化された機能
参照 参照 参照
15
Xamarin Component Store
追加コンポーネントで簡単機能追加
16
Storyboard / XIBAndroid Designer
ネイティブAXMLBlendBlend
MvvmCross
ViewView View
ViewModel
PCL( Portable Class Library )Model
オフラインサポート
エンタープライズモバイルアプリのデータ利用シナリオ
オフラインデータ操作
・ローカルテレメートリーデータ・分散数値計算処理、等々…
・ワークフロー・ユーザー入力 / 更新
Table Controller
デバイス
SQLite
Database
Mobile Services
Push/Pull
データベース作成とテーブルの定義・MobileServiceSQLiteStore ・データベース作成と テーブル作成を wrap・ Client /Server 双方に作成 - オフラインデータ用クラス・標準的な SQL DDL は不要
データベースの作成
テーブルの作成
オフラインサポートの実装 Demo
Microsoft Azure Active Directory 連携
Microsoft Account, Twitter, Facebook, Google ID Microsoft Azure Active Directory 各 CRUD 操作へのアクセス許可の設定方法
サーバーサイドスクリプト( Node.js )コントローラーの各メソッド( .NET )
認証
Azure Active Directory と Mobile Services 組織 ID 利用モバイル LOB アプリ開発
可能 Microsoft Azure Active Directory ユー
ザー
Active Directory Authentication Library (ADAL)Microsoft Azure Active Directory によっ
て保護されたリソースへのログインを可能に
複数の企業リソースへのシングルサインオンを提供
Windows ストアアプリ、 iOS/Android アプリ
各プラットフォームで利用可能
1) クライアントアプリが ADAL を使ってログインを試行。ユーザーが入力したクレデンシャル情報を Azure AD に送信
2) Azure AD は Mobile Services のためのアクセストークンと リフレッシュトークンのペアをADAL に返送
3) クライアントは、当該 アクセストークン を Mobile Service に 渡し、 Mobile Services トークンに変換して、セッションを継続
基本的な ADAL + Mobile Services のフロー
3
2
1
string authority = “https://login.windows.net/< テナント名 >.onmicrosoft.com”;string resourceURI = “https:// サービス名 .azure-mobile.net/login/aad";string clientID = “<Azure Active Directory ポータルから入手した Client App ID>";
AuthenticationContext ac = new AuthenticationContext(authority);
AuthenticationResult ar = await ac.AcquireTokenAsync(resourceURI, clientID);
string accessToken = ar.AccessToken;
// Mobile Services にアクセストークンを付与
JObject payload = new JObject();
payload["access_token"] = accessToken;
MobileServiceUser user = await
App.MobileService.LoginAsync(
MobileServiceAuthenticationProvider.
WindowsAzureActiveDirectory, payload);
基本的な ADAL + Mobile Services のフロー
Active Directory 連携による Mobile Services アプリ認証 Demo
DevicesOffice 365 ※
認証
予定更新
Microsoft AzureMobile
Servicesデータ更新
など
Database
SQL Azure Database と Exchange Online の予定表の双方にイベントを追加
※ Mobile Services により ID プロバイダー部分以外は全て共通ロジックで 実装可能
1) Mobile Service がリソースの URI と Client ID / Client Secret つきで、アクセストークンを Azure AD に送信
2) Azure AD はリモートリソースのためのアクセストークンとリフレッシュトークンのペアを返送
3) Mobile Service がログイン済ユーザーを代行してリモートリソースとコミュニケート
拡張シナリオ : リソースへのログイン代行
1 2
3
ServiceUser user = ( ServiceUser ) this.User;
AzureActiveDirectoryCredentials creds = (await user.GetIdentitiesAsync())
.OfType<AzureActiveDirectoryCredentials>()
.FirstOrDefault();
string accessToken = creds.AccessToken;
string authority = “https://login.windows.net/ テナント名 .onmicrosoft.com";
string resourceURI = "http://myresource";
string clientId = “b69ee3c9-c40d-4f2a-ac80-961cd1534e40“ ; //Mobile Services から取得
string clientSecret = “oF2LC0pLyfwvUwT61/oVUJ+U8AuwTu+Lyorzt3yZTtE=“ ; //Mobile Services から
AuthenticationContext ac = new AuthenticationContext (authority);
AuthenticationResult ar = ac.AcquireToken(resourceURI, new UserAssertion(accessToken),
new ClientCredential(clientId, clientSecret));
string resourceToken = ar.AccessToken;
拡張シナリオ : リソースへのログイン代行
Active Directory 連携による Mobile Services ( SQL )と Exchange Online への同時書き込み
Demo
Xamarin + Mobile Services でパワフルにアプリ開発!
プッシュ通知
データベース
ユーザー認証
バックエンド
Node.js Express
ASP.NET Web API
SQL Table Storage
Blob Storage
WNS & MPNS
APNS GCM
Mongo DB
Notification Hubs
ソース管理
Twitter Microsoft Google Azure Active
Directory
Windows ストアiOSAndroid XamarinPhoneGapSencha
Windows PhoneiOSAndroidHTML 5/JS
クライアントSDK
Hybrid Connections
RE
ST A
PI
Microsoft Azure Mobile Services http://azure.microsoft.com/ja-jp/services/mobile-services/ チュートリアル http://azure.microsoft.com/ja-jp/develop/mobile/ 講演者ブログ http://blogs.msdn.com/b/shosuz/
リソース
© 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.