Azure Mobile Apps with Xamarin

download Azure Mobile Apps with Xamarin

If you can't read please download the document

  • date post

    14-Apr-2017
  • Category

    Mobile

  • view

    222
  • download

    3

Embed Size (px)

Transcript of Azure Mobile Apps with Xamarin

PowerPoint Presentation

Dan HermesXamarin MVPPresident, Lexicon [email protected]

Azure Mobile Apps with Xamarin

1

About meSoftware consultant since 1999Code, write, and lead teams Minecraft, tiki cocktails, my parrot, and digital artI love Xamarin

2

This weighty book gives clear guidance that will help you build quality apps, starting with architectural considerations, and then jumping into practical code strategies. - Bryan Costanich, Vice President, Xamarin

Dan Hermes extraordinary book is the most intelligent work on cross-platform mobile development Ive seen. Jesse Liberty, Director of New Technology Development, Falafel Software, Xamarin Certified Developer / Xamarin MVP

3

Book Tour

Book Tour

Why are we here?

Julie Larson-Green Microsoft, Xbox Division6

We Apps

Everybody Apps!

189Mdownloads a day

200mins on phone

127mins in apps

The average app user has 36 apps installed on his or her phone.

Google survey9

Only 1/4 are used daily:

1/4 of apps are never used!

Why not?

Bad App Experiences

Slow or laggyCrashesUnintuitive & bad UXFeatures not as advertisedData not available when you need it

Your app craves connection more than you do.

http://opensignal.com/coverage-maps

No app is an island

Every app needs a serverDatabasesServicesAuthenticationNotificationsFiles

in the cloud, of course

The native API coverage that Jesse was talking about earlier17

Plenty of Options

Amazon Web ServicesAzure Mobile AppsIBM MobileFirst Oracle Mobile CloudSQLCIipherCouchbaseRealmSQLite-net

Left: Online - connectedRight: Offline - disconnected18

Extremely powerfulFlexibleEasy TablesApp ServiceC# SDKs available everywhere:C#- iOS, Android, & Windows with XamarinC# clients, written by C# developers (open source)C# backend with ASP.NET

Why Azure?

Extremely powerfulYou can do almost anything your backend would ever need to do with Azure. Data storage, authentication/authorization, push notifications, custom APIs, blob storage, etc.FlexibleNeed something lightweight? Azure is there.Need something robust and powerful? Azure is there.C# clientsIm a frontend developer, I care a lot about how easy this makes MY job (selfish)Many C# clients are written by Java developers, etc.Easy to use C# clientAbstracts away much of pain of using a RESTful APIC# FeaturesAsync / Await / TPLUses C# idiomsProperties, Fluent APISeems obvious, but not always true (first class citizen)

19

What is Microsoft Azure App Service?Data storage with Azure SQL DatabaseAPI creationAuthentication and AuthorizationPush NotificationsJob processingA platform-as-a-service (PaaS) offering of Microsoft AzureA ready-made backend so the developer can focus on the app

Notes:App Service aims to automate the creation of very common line-of-business mobile and web functionalityThe developers can focus on developing the parts of the app that are unique as opposed to the boilerplate, typical scenarios that must be re-created for each application

20

What are Azure Mobile Apps?

Storage

Authentication

Push

Courtesy of Microsoft

Notes:Azure Mobile Apps is an app type of Azure App Service (others types include Web Apps, API Apps, and Logic Apps)

Users dont really care (and usually dont know) what a mobile app is using for its backendUsers care most about enjoying the app experienceDevs should therefore spend most of their time building the best client experience they canAzure Mobile Apps helps devs by providing common mobile app backend features in a turnkey mannerData storage powered by SQL Database (but you dont have to be a Database Admin to use it)User Authentication and Data AuthorizationPush Notifications (using services built into Android, iOS, Windows, and more)

Other topics not covered in this lesson:Backend job processing using the schedulerBackend Logic

Image and text courtesy of Microsoft

21

Storage, Authentication, and Push Notifications

Courtesy of Microsoft

References:Image courtesy of Microsoft22

How Do I Use Azure App Service?Azure Portal for configuration of entitiesServer SDK in C# or Node.JSClient SDKs for Xamarin and third-party productsAzure Portal for configuration of entitiesServer SDK in C# or Node.JSClient SDKs for Xamarin and third-party products

Notes:By following the step-by-step wizard-like process in App Service in the browser, you can add common functionality thats pre-configured to work with your Azure instance and other apps and services youve built in your Azure instance

23

Lets add a backend

Create a new Azure Mobile App

Notes:Select New > Web + Mobile > Mobile App25

Quick Start in Settings and Connect a DB

Notes:Select New > Web + Mobile > Mobile App1 Connect to a Database (create a DB connection)2 Create a table API (C# or Node.js)3 Configure your client application26

Azure Mobile App API - DefineTableSQL CREATE TABLESql Server Management StudioEasy TablesEntity Framework

For the demo just click Create ToDoItem Table:Create your Tables

What if a GetAll should only return favorites for that user.27

Create a new Azure Mobile App backendBuild, upload, and test the server projectCreate a client mobile application

or Just Use Azures Built-in Table APICreate a Table API using C#

What if a GetAll should only return favorites for that user.28

Create a client mobile applicationClickCreate a new appClick Download buttonOpen Solution in Visual Studio or Xamarin Studio

Notes:You can download the solution to a Mac and open it in Xamarin Studio, or you can download the solution to a Windows computer and open it in Visual Studio using a networked Mac for building the iOS app.Extract the project that you downloaded, and then open it in Xamarin Studio or Visual Studio.29

Create a Mobile ServiceMobileService = new MobileServiceClient("https://myapp.azurewebsites.net");

Add Azure Nuget301/19/2017 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

Now lets get to the data

Create TablesIMobileServiceSyncTable table;public async Task Init(){ const string path = "syncstore.db"; var db = new MobileServiceSQLiteStore(path); db.DefineTable();

}

var handler = new MobileServiceSyncHandler(); await MobileService.SyncContext.InitializeAsync(db, h); table = MobileService.GetSyncTable();

321/19/2017 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

Get and Modify Datapublic async Task GetStoresAsync(){ await table.PullAsync("allStores", table.CreateQuery()); return await table.ToEnumerableAsync();}public async Task AddStoreAsync (Store store){ await table.InsertAsync (store); await table.PullAsync("allStores", table.CreateQuery()); await MobileService.SyncContext.PushAsync(); return store;}

331/19/2017 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

Table-based SQL databaseInstances configurable using the Azure portalData management in:Azure PortalSQL Portal (Silverlight)SQL Management StudioREST APIAzure CLI ToolsSQL CLIAzure SQL Database

What if a GetAll should only return favorites for that user.34

Threat detection and alertsAuditingEmail upon anomaly detectionAutomatic tuningIndex(create and drop), query parameter, schema recommendationsNo administration requiredAutomatic backups and updatesAzure SQL Database

What if a GetAll should only return favorites for that user.35

Data Access Anti-PatternData StoreAppData Access CallsData Access CallsData Access CallsCourtesy of Microsoft

Notes:Calls to the data store can be made in the app directly f