38
Xamarin から使う Azure 2017/7/25(火) 第7回 Tokyo Jazug Night Japan Xamarin User Group 田淵義人@エクセルソフト Twitter: @ytabuchi facebook: ytabuchi.xlsoft

Xamarin から使う Azure

Embed Size (px)

Citation preview

Page 1: Xamarin から使う Azure

Xamarin から使う Azure

2017/7/25(火)第7回 Tokyo Jazug Night

Japan Xamarin User Group

田淵義人@エクセルソフト

Twitter: @ytabuchi

facebook: ytabuchi.xlsoft

Page 2: Xamarin から使う Azure

営業(セールスエンジニア) 兼 新規事業開発室 室長Xamarin コミュニティエバンジェリストMicrosoft MVP Visual Studio and Development TechnologiesXamarin MVP

連載・執筆Build Insider Xamarin Tips.NET開発テクノロジ入門2016年版

コミュニティJapan Xamarin User Group 主宰Twitter: @ytabuchifacebook: ytabuchi.xlsoftBlog: Xamarin 日本語情報

2

田淵義人@エクセルソフト

Page 3: Xamarin から使う Azure

開発者向けソフトウェア販売代理店クラウドサービスもやりたいなぁ

取り扱いのないソフトウェア、サービスもスポットで可能日本円で買いたい海外製品があれば @ytabuchi まで

新規取り扱い製品もどんどん増えてます

3

エクセルソフトの宣伝

Page 4: Xamarin から使う Azure

注意事項

2017/7/25 時点の情報です。

4

Page 5: Xamarin から使う Azure

Xamarin とは

Page 6: Xamarin から使う Azure

C#/.NET/Visual Studio

フル “ネイティブ” アプリ

API 100% 移植

コード共通化

6

Xamarin

Page 7: Xamarin から使う Azure

C#

7

button.Click += async (sender, e) =>{

var client = new HttpClient();using (var reader = new StreamReader(await client.GetStreamAsync("xxx"))){

var deserializer = new XmlSerializer(typeof(Rss));var latest = deserializer.Deserialize(reader) as Rss;var feed = latest.Channel.Items

.Where(x => x.Link.Contains("xamarin"))

.Select(x => x.Title).ToList();}

};

Page 8: Xamarin から使う Azure

2つの開発手法

8

Shared C# App Logic

(PCL)

Shared XAML/C# UI Code

(Xamarin.Forms)

iOS

C# UI

Shared C# App Logic

(PCL)

Android

C# UI

Windows

C# UI

Xamarin.FormsXamarin Nativeロジックのみ共通化

UIはネイティブで個別に作りこむ

Page 9: Xamarin から使う Azure

Xamarin から使う Azure

Page 10: Xamarin から使う Azure

Xamarin から使う Azure の前に

Page 11: Xamarin から使う Azure

PCL/Shared Project

Page 12: Xamarin から使う Azure

Xamarinと、ポータブル・クラス・ライブラリ(PCL) - Build Insider

Xamarin.Forms の PCL ではどの Profile を選択すべきか? -Xamarin 日本語情

NuGet Package Explorer

12

Portable Class Library(PCL)とは

Page 13: Xamarin から使う Azure

13

Page 14: Xamarin から使う Azure

.NET Standard

14

Page 15: Xamarin から使う Azure

15

https://channel9.msdn.com/Events/de-code/2017/TL04

Page 16: Xamarin から使う Azure

16

https://channel9.msdn.com/Events/de-code/2017/TL04

Page 17: Xamarin から使う Azure

.NET Standard | Microsoft Docs

主に技術日記: .NET Standard のおさらい

さいきんの.NETのこととかNuGetとかCoreとかよく分からないよねーって話 - Qiita

Xamarin.Forms+.NET Standard 1.6を試す – Takashi Kawasaki – Medium

.NET Standard

Page 18: Xamarin から使う Azure

Target Frameworks References for NuGet | Microsoft Docs

PackageTargetFallback (new design for Imports) · NuGet/Home Wiki

Oren Novotny » Using Xamarin Forms with .NET Standard – VS 2017 Edition

18

.NET Standard

Page 19: Xamarin から使う Azure

.NET Standard 対応

19

.NET Standard 1 1.1 1.2 1.3 1.4 1.5 1.6 2

.NET Core 1 1 1 1 1 1 1 2

.NET Framework (*1) 4.5 4.5 4.5.1 4.6 4.6.1 4.6.2 vNext vNext

.NET Framework (*2) 4.5 4.5 4.5.1 4.6 4.6.1 4.6.1 4.6.1 4.6.1

Mono 4.6 4.6 4.6 4.6 4.6 4.6 4.6 vNext

Xamarin.iOS 10 10 10 10 10 10 10 vNext

Xamarin.Android 7 7 7 7 7 7 7 vNext

Universal Windows Platform 10 10 10 10 10 vNext vNext vNext

https://docs.microsoft.com/ja-jp/dotnet/standard/library

Page 20: Xamarin から使う Azure

Microsoft Azure

Page 21: Xamarin から使う Azure

Mobile Apps

21

Page 23: Xamarin から使う Azure

Notification Hubs

23

Page 24: Xamarin から使う Azure

Sending Push Notifications from Azure Mobile Apps –Xamarin

Add push notifications to your Xamarin.Forms app | Microsoft Docsこれが最新

Push ServicesApple Push Notification Service (APNS)

Firebase Cloud Messaging (FCM)

Windows Notification Service (WNS)

24

Notification Hubs

Page 25: Xamarin から使う Azure

25

通知の例

Page 26: Xamarin から使う Azure

Cognitive Services

26

Page 27: Xamarin から使う Azure

「cognitive」で検索

Cognitive Services のSDK有無@201707 -BEACHSIDE BLOG

27

Azure Portal

Page 28: Xamarin から使う Azure

28

private async Task<OcrResults> UploadAndRecognizeImage(Stream imageStream, string language){// Create Project Oxford Vision API Service clientVisionServiceClient VisionServiceClient = new VisionServiceClient(Secrets.ComputerVisionApiKey,"https://southeastasia.api.cognitive.microsoft.com/vision/v1.0"

);

// Upload an image and perform OCROcrResults ocrResult = await VisionServiceClient.RecognizeTextAsync(imageStream, language);return ocrResult;

}

SDK

Page 29: Xamarin から使う Azure

29

public static async Task<string> DoOcrStreamAsync(Stream imageStream, string lang){using (var client = new HttpClient()){// ヘッダーとパラメーターを付与したリクエストを作成client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", Secrets.ComputerVisionApiKey);var sendUri = $"{uriBase}?language={lang}&detectOrientation=true";

// StreamをコンテントとしてPOSTするvar content = new StreamContent(imageStream);content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");var response = await client.PostAsync(sendUri, content);response.EnsureSuccessStatusCode();

// JSONを取得してデシリアライズstring contentString = await response.Content.ReadAsStringAsync();var ocrResultString = JsonConvert.DeserializeObject<OcrResult>(contentString);

}}

REST

Page 30: Xamarin から使う Azure

分析

テキストの読み取り

手書き文字の読み取り(プレビュー)

著名人およびランドマークの認識

ほぼリアルタイムでビデオを分析

サムネイルの生成

30

Computer Vision API

Page 31: Xamarin から使う Azure

60 以上の言語のテキスト間での翻訳

自動的に言語を検出

独自翻訳システムを構築

31

Translator API

Page 32: Xamarin から使う Azure

POSThttps://southeastasia.api.cognitive.microsoft.com/vision/v1.0/ocr

HeaderOcp-Apim-Subscription-Key

Cotent-Type

Cotentapplication/json

multipart/form-data

application/octet-stream

32

REST API

Page 33: Xamarin から使う Azure

Tokenhttps://api.cognitive.microsoft.com/sts/v1.0/issueToken

Ocp-Apim-Subscription-Key からToken

GETappid

text

from

to

category

33

REST API

Page 34: Xamarin から使う Azure

Emotional APIEmotion Recognition Using the Emotion API - Xamarin

Cosmos DBConsuming an Azure Cosmos DB Document Database - Xamarin

Azure StorageStoring and Accessing Data in Azure Storage - Xamarin

Azure SearchSearching Data with Azure Search - Xamarin

34

その他の Azure/Xamarin

Page 35: Xamarin から使う Azure

Azure AD B2CXamarinアプリの認証にAzure AD B2Cを使ってみよう | PaaSがかりの部屋

Bot FrameworkBot FrameworkのDirect Line APIをXamarin.Formsから使う場合のサンプルプログラム - かずきのBlog@hatena

Cognitve Services/Cosmos DBXamarin.Forms と Azure の組み合わせサンプル書いてみたよ - かずきのBlog@hatena

35

おつよい皆様

Page 36: Xamarin から使う Azure

まとめ

Page 37: Xamarin から使う Azure

仮想マシンで使うのはもったいない

PaaS!PaaS!PaaS!

Xamarin(モバイル)と絡めると更に面白い!

jazug/JXUG の合同勉強会やハンズオンを(野望)

Azure は面白い

Page 38: Xamarin から使う Azure

ありがとうございます

田淵義人@エクセルソフト

Twitter: @ytabuchi

facebook: ytabuchi.xlsoft

080-7015-3586

38