of 49 /49
Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

Embed Size (px)

Text of Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner...

Page 1: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

Cloud Powered Android Apps in MinutesChris RisnerSenior Technical Evangelist@chrisrisner Microsoft Azure

Page 2: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

2

About me

Technical Evangelist @chrisrisner

Chrisrisner.com Live in Washington

Grew up in MichiganMobile dev for 5+

years

Page 3: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

3

Agenda

Microsoft Azure Mobile Services

Features and Demos Advanced Features

Scaling and Pricing Questions

Page 4: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

4

What is Azure?•Hosting and Services•Massively scalable•Geographically available•Affordable

Page 5: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

What is Mobile Services?

5

Storage

AuthenticationLogic

Push

Scheduler

Page 6: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

Demo: Getting StartedYour first Mobile Service

Page 7: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

7

Structured Storage• Powered by SQL Database• Supports rich querying capabilities• Dynamic Schematization• Data management in:• Azure Portal• SQL Portal (Silverlight)• SQL Management Studio• REST API• Azure CLI Tools• SQL CLI

Microsoft Azure

Page 8: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

8

The REST API

Action HTTP Method URL Suffix

Create POST /TodoItem

Read GET /TodoItem?filter=id%3D42

Update PATCH /TodoItem/id

Delete DELETE /TodoItem/id

Microsoft Azure

Base Endpoint: https://MobileService.azure-mobile.net/tables/*

Page 9: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

9

JSON to SQL Type Mappings

JSON Type T-SQL Type

Numeric values (integer, decimal, floating point)

Float(53)

Boolean bit

DateTime DateTimeOffset(3)

String Nvarchar(max)

Microsoft Azure

Page 10: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

10

Auto-generated Columns• id – unique guid• __createdAt – date• __updatedAt – date

• __version – timestamp• Helps with concurrency and offline

Microsoft Azure

Page 11: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

11

Offline• Currently in beta• http://aka.ms/lajk6q

• Walkthrough• http://azure.microsoft.com/blog/2014/08/07/offline-support-in-

azure-mobile-services-android-sdk/

• Uses Futures and callbacks• Sync Tables

Microsoft Azure

Page 12: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

Backend Logic:.NET & JavaScript

Page 13: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

13

Server Side Table Scripts

Node.js scripts.NET Web APIbackend in

Visual Studio

Passes through to SQL by default

MongoDB, Table Storage, SQL out of

the box

Intercept CRUD requests to tables

Fully customizable

Page 14: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

14

Node Modules

request push.*

console mssql

tables azure

sendgrid

pusher

twilio

Page 15: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

Demo: Customizing LogicAdding Data Validation

Page 16: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

16

.NET Backend• Web API based w/ additional functionality, developed in and

deployed from Visual Studio• TableController data context can map to SQL, Table Storage,

Mongo, etc• Pull in NuGet modules and other .NET libraries• Set permissions with attributes on classes• Local Debug

Microsoft Azure

Page 17: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

17

Custom API• Non-table based endpoints• Accessible from

• GET• POST• PUT• PATCH• DELETE

• For node.js logic in scripts like table endpoints

• For .NET delivered through a WebAPI

• Expose any functionality you want

Microsoft Azure

Page 18: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

18

File Storage• Don’t store files in Mobile Services DB• Use Mobile Service to provide a Valet Key Pattern to Blob

Storage, aka BLOB SAS• Create table / custom API script to talk to Blob Storage• Script generates Shared Access Signature (SAS) URL• Script returns SAS URL to client app• Client app uploads data to blob storage directly• Store file URL in Mobile Service DB as needed

• Blob storage costs less and is built for redundant file storage

• Use the Resource Broker • https://github.com/Azure/azure-mobile-services-resourcebroker

Microsoft Azure

Page 19: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

Push Notifications

Page 20: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

20

Push Notification Flow

Microsoft Azure

1.

2.

3.

4.

Client

(1)

(2)

(3)

(4)

Page 21: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

Demo: Adding Push

Page 22: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

22

Notification Hubs• Separate from Mobile Services

• Can be used regardless of whether you’re storing data in Azure

• Extremely scalable push notifications

• Cross platform support• Push to iOS, Android, Kindle, Windows Phone, Windows Store

• Tags (i.e. tie my registration to this topic or user ID)

• Templates (i.e. when I get a push, send it in this format)

• Connect to using Azure module

Microsoft Azure

Page 23: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

Authorization&Authentication

Page 24: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

24

Data Authorization• Per HTTP method auth options:

• App Key Required• Not ideal for production use

• Everyone• Authenticated Users• Admins and other scripts

• Requires Master Key as header

• 401 Unauthorized response if security check fails

Microsoft Azure

Page 25: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

25

User Auth Flow (server)

Microsoft Azure

GOOGLE

FACEBOOK

TWITTER

MOBILE SERVICE

DEVICE

CREDENTIALS

(via

oAuth/WebView)

MICROSOFT

IDEN

TITY

AUTH

TO

KEN

GRA

PH A

CCES

S (L

IMIT

ED)

Page 26: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

26

User Auth Flow (client)

Microsoft Azure

GOOGLE

FACEBOOK

TWITTER

MOBILE SERVICE

DEVICE

MICROSOFT

AUTH CODE

AUTH CODE + TOKEN

GRAPH

ACCES

S

CREDENTIALS

(via native SDKs)

IDENTITY

GRAPH ACCESS

Page 27: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

27

The User object• User.level

• Admin• Authenticated• Anonymous

• User.userId• Provider:id or undefined

• User.getIdentities()• UserId• Provider Access Token / Secret• Basic user information (i.e. name, username, locale, picture, link)

Microsoft Azure

Page 28: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

Demo: Adding AuthLock Down and Login

Page 29: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

Command Line Interface

Page 30: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

30

CLI

Create / Delete ServicesInspect / Delete Table

Data

Create / Update / Delete Tables and

Permissions

Create / Upload / Delete Scripts

Scale Up / Down Services

Much More Across Azure

Page 31: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

Demo: Using the CLI

Page 32: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

Scheduler

Page 33: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

33

Scheduled Jobs• Executes a script on defined schedule• Can be run on demand• Ideal for any backend data processing job

Microsoft Azure

Page 34: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

ScriptSourceControl

Page 35: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

35

Script Source Control• Creates a Git repo in Azure• Access table, scheduler, custom API, shared scripts and

permissions• Pushing changes triggers a redeploy of your Mobile Service• Enables installing NPM modules

• Shared Scripts• Create scripts that can be used from all other scripts in your

Service

Microsoft Azure

Page 36: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

DiagnosticsLoggingScale

Page 37: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

37

Diagnostics, Logging, Scale

API Calls, # of Devices, Data Out

Console Logging (auto error logging)

Scale Service Based off API Calls

Auto-scale to Save Money

Free Tier for Mobile Free Tier for SQL

Page 38: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

Mobile Service Scaling Free: 500k calls / month / subscription Basic: 1.5M calls / unit (6) / month Standard: 15M calls / unit (10) / month

Page 39: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

Demo: ScalingLeaving Free Mode and Turning on AutoScale

Page 40: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

40

Mobile Service Tiers

Microsoft Azure

usage & licensing $ service level

agreements

General Availability99.9%

Free Basic Standard

Usage Restrictions

Up to 10 services,Up to 500 Active

Devices*

N/A N/A

API Calls 500K (per subscription)

1.5M(per unit)

15M(per unit)

Scale N/A Up to 6 (in portal)

Up to 10 (in portal)

Scheduled Jobs

Limited Included Included

SQL Database (required)

20MB free DB 20MB free DB 20MB free DB

*Active devices refers to the number of physical devices and emulators that make at least one call to or receive a push notification from your mobile service.

Page 41: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

Azure Mobile Services

41

Storage

AuthenticationLogic

Push

Scheduler

Page 42: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

42

Other Azure Resources for Android• Azure Notification Hubs• Azure Storage Library for Android• Azure Plugin for Eclipse / Android Studio / IntelliJ• Office 365 SDK• SharePoint SDK• Azure Active Directory Authentication Library• VSO for source control and CI

Microsoft Azure

Page 43: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

43

Resources• Get a FREE Microsoft Azure Trial Account:

• http://azure.microsoft.com

• Videos, Tutorials, and More• http://azure.microsoft.com/android

• SDK Source Code on GitHub• https://github.com/Azure/azure-mobile-services

• Contact Details• http://chrisrisner.com• http://aka.ms/CommonWams• @chrisrisner

Microsoft Azure

Page 44: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

Thanks!Questions?

Page 45: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

© 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.

Page 46: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

Azure footprint

16 regions worldwide in 2014

Page 47: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

Fortune 500 using Azure

>57%

>250kActive websites

Greater than

1,000,000

SQL Databases in Azure>20 TRILLION

storageobjects

>300

MILLIONAD users

>13BILLIONauthentication/wk

>2 MILLION

requests/sec

>1 MILLION

Developers registered with Visual Studio Online

Page 48: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure
Page 49: Cloud Powered Android Apps in Minutes Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

Get startedVisit azure.microsoft.com