• No results found

Cloud Powered Mobile Apps with Microsoft Azure

N/A
N/A
Protected

Academic year: 2021

Share "Cloud Powered Mobile Apps with Microsoft Azure"

Copied!
45
0
0

Loading.... (view fulltext now)

Full text

(1)

Cloud Powered Mobile Apps

with Microsoft Azure

Malte Lantin

Technical Evanglist

Microsoft Azure

(2)

Malte Lantin

Technical Evangelist, Microsoft Deutschland

Fokus auf Microsoft Azure, App-Entwicklung Student Partner Program Lead

Blog unter http://blogs.msdn.com/b/malte_lantin Twitter @MalteLantin

[email protected]

Seit 5 Jahren bei Microsoft

Microsoft Student Partner / Universität Duisburg-Essen Diplom Wirtschaftsinformatiker

Seit Anfang 2010 bei Microsoft in unterschiedlichen Rollen (Product / Audience Marketing, Technical Evangelism)

Sprecher auf diversen Konferenzen und Veranstaltungen

(3)

cloud/mobile

server/client

(4)

Scenarios for the cloud

Temporary Resources

Load

Time

Flexible Growth

Load

Time

Load Peaks

Load

Time

Access from anywhere and any time



(5)

On Premises

You scale, make resilient and manage

Infrastructure

(as a Service)

Managed by vendor

You scale, make resilient & manage

Platform

(as a Service)

Scale, resilience and management by vendor

You manage

Hosting models

Software

(as a Service)

Business model

Applications

Scale, resilience and management by vendor

Why the cloud?

(6)

Azure

(7)

Microsoft Azure Services

Client layer (on-premises)

Tablet Phone Games

console

PC On-premises

database Browser

Office Add-in On-premises

service

AD

Multifactor Authentication

Access Control LayerIntegration layer Service Bus CDNBizTalk

Services Traffic

Manager Virtual

Networks Express Route

Application layer API Mgmt Web Apps Cloud

Services VM

Mobile Apps Media

Services Notification

Hubs Scheduler Automation

Data Layer

Storage Blobs Tables Queues Data Machine

Learning HD Insight Backup and

Recovery

SQL Database Caching StorSimple

API Apps Logic Apps

(8)

How to use Microsoft Azure

>_

REST API

Management portal

Scripting

(Windows, Linux and Mac)

Pure HTML / JavaScript – works in every modern browser

CLI for Windows, Linux & Mac – PowerShell for Windows

Use in you own applications – used by Management Tools

(9)

Web Services und Microsoft Azure

• REST-based Web Services are an essential part of the

platform

1. Provisioning of Web Services as components of larger

cloud services and modern web applications

• e.g. Azure Mobile Services, API-Management

2. Management of services in Microsoft Azure through web

services

• z.B. POST https://management.core.windows.net/<subscription- id>/services/hostedservices/<cloudservice-name>/deployments

(10)

Where do we come from?

• Remote Procedure Calls (RPC)

• Actions in endpoints

• GetCustomer

• InsertInvoice

• DeleteCustomer

• Every endpoint corresponds to one URI

(11)

Representational State Transfer (REST)

• REST is not a standard but uses standards

• Architectural Concept

• Roy Fielding in 2000

• “Architectural Styles and the Design of Network-based

Software Architectures”

• HTTP Stack, explicit use of HTTP methods / verbs

(12)

Design principles of REST

• stateless

• URIs with folder structure

• XML, JavaScript Object Notation (JSON) or both

• Transfer of data snapshots in the message body

• Not commands or methods in message body

(13)

Anatomy of HTTP-messages

Request

Request Line

Request Headers

Request Body

Antwort Response

Status Line

Response Headers

Response Body

(14)

Example: GET

• Request

• GET http://localhost:21697/api/employees/12345 HTTP/1.1

• User-Agent: Fiddler

• Host: localhost:21697

• Response

• HTTP/1.1 200 OK

• Content-Type: application/json; charset=utf-8

• Date: Tue, 04 Nov 2014 15:48:03 GMT

• Content-Length: 50

• {"Id":12345,"FirstName":"John","LastName":"Human"}

(15)

HTTP-Methods

• Create, Read, Update und Delete (CRUD) mapped to

http methods

• Create  POST

• Read  GET

• Update  PUT

• Delete  DELETE

• Design principles: nouns instead of verbs

(16)

Example: POST

https://management.core.windows.net/<subscription-

id>/services/hostedservices/<cloudservice-

name>/deployments

http://msdn.microsoft.com/en-

us/library/azure/jj157194.aspx

(17)

Azure Mobile Services

 Mobile Services

 Features and Demos

 Advanced Features

 Scaling and Pricing

(18)

What are Mobile Services?

18

Storage

Authentication

Logic

Push

Scheduler

(19)

Demo: Getting Started

Your first Mobile Service

(20)

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

20

Microsoft Azure

(21)

The REST API

21

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/*

(22)

JSON to SQL Type Mappings

22

JSON Type T-SQL Type

Numeric values (integer, decimal,

floating point) Float(53)

Boolean bit

DateTime DateTimeOffset(3)

String Nvarchar(max)

Microsoft Azure

(23)

Auto-generated Columns

• id – unique guid

• __createdAt – date

• __updatedAt – date

• __version – timestamp

• Helps with concurrency and offline

23

Microsoft Azure

(24)

Backend Logic:

JavaScript & .NET

(25)

Server Side Table Scripts

25

Node.js scripts

Intercept CRUD

requests to tables

Passes through to SQL

by default

Fully customizable

.NET Web API

backend in

Visual Studio

MongoDB, Table

Storage, SQL out of the

box

(26)

.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

26

Microsoft Azure

(27)

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

27

Microsoft Azure

(28)

Demo: Dynamic Schema

(29)

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

• Resource Broker extension for .NET and Node backends

29

Microsoft Azure

(30)

Push Notifications

(31)

Push Notification Flow

31

Microsoft Azure

(32)

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)

• Server SDKs for .NET, Java, and Node (also open as REST API)

32

Microsoft Azure

(33)

Authorization

&

Authentication

(34)

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

34

Microsoft Azure

(35)

User Auth Flow (server) GOOGLE

FACEBOOK

TWITTER

MOBILE SERVICE

DEVICE

MICROSOFT

ACCOUNT

AAD

(36)

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)

36

Microsoft Azure

(37)

Script

Source

Control

(38)

Script Source Control

• Creates a Git repo in Azure

• Node.js only, turned on by default

• Access table, scheduler, custom API, shared scripts and permissions

• Pushing changes triggers a redeploy of your Mobile Service

• Enables installing NPM modules (for Node backends)

• Shared Scripts

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

38

Microsoft Azure

(39)

Diagnostics

Logging

Scale

(40)

Diagnostics, Logging, Scale

40

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

(41)

Mobile Service Scaling

 Free: 500k calls / month / subscription

 Basic: 1.5M calls / unit (6) / month

 Standard: 15M calls / unit (10) / month

Microsoft Azure

(42)

Demo: Scaling

Leaving Free Mode and Turning on AutoScale

(43)

Azure Mobile Services

43

Storage

Authentication

Logic

Push

Scheduler

(44)

Task for next week

Use Azure Mobile Services to add user authentication

to your apps

• http://aka.ms/azuremobileauth

• Choose MS Account, Facebook, Twitter, Google

Save information per user after login

44

(45)

References

Related documents

The solutions that are part of the Noah Mobile cloud service are based on the core Platform-as-a-Service (PaaS) services on the Microsoft Azure Platform.. The Noah Mobile

Windows Azure Active Directory and the Hybrid Enterprise - Today Windows Azure Active Directory On‐premises and private cloud Other apps Other Directories Self‐Service

In 2012, Microsoft launched Windows Azure Mobile Services: cloud mobile back-end services that support iOS, Android and cross-platform mobile HTML/JavaScript hybrid app

Web Identity Auth Flow User ID (Temp Credentials) DynamoDB End Users Developer App w/SDK Access to AWS Services Cognito Identity Broker Login OAUTH/OpenID Access Token

In 2012, Microsoft launched Windows Azure Mobile Services: cloud mobile back-end services that support iOS, Android and cross-platform mobile HTML/JavaScript hybrid app development,

In 2012, Microsoft launched Windows Azure Mobile Services: cloud mobile back-end services that support iOS, Android and cross-platform mobile HTML/JavaScript hybrid app

In 2012, Microsoft launched Windows Azure Mobile Services: cloud mobile back-end services that support iOS, Android and cross-platform mobile HTML/JavaScript hybrid app development,

As a Microsoft Gold partner for Cloud Platform, Ultima are able to help you use RemoteApp to implement an agile, cloud-based application delivery platform, powered by Azure and