Building Push Triggers for Logic Apps

33
Sponsored & Brought to you by Building Push Triggers for Logic Apps Nicholas Hauenstein http://www.twitter.com/nickhauenstein https://www.linkedin.com/in/nickhauenstein

Transcript of Building Push Triggers for Logic Apps

Page 1: Building Push Triggers for Logic Apps

Sponsored & Brought to you by

Building Push Triggers for Logic AppsNicholas Hauenstein

http://www.twitter.com/nickhauenstein

https://www.linkedin.com/in/nickhauenstein

Page 2: Building Push Triggers for Logic Apps

Building Push Triggers for Logic AppsNick HauensteinMicrosoft Integration MVPPrincipal Software Development Engineer, QuickLearn Training@nickhauenstein

Page 3: Building Push Triggers for Logic Apps

About MeNick Hauenstein [email protected]

17 years development experience 14 years .NET experience Integration entry point: BizTalk Server 2006 Member of the ESB Toolkit 2.0 Team Blogger (quicklearn.com/blog)

200+ pages on BizTalk Server 2013 & 2013 R2

Granted rights to display all these nifty icons:

Page 4: Building Push Triggers for Logic Apps

Let’s start with a story…

Page 5: Building Push Triggers for Logic Apps

Typical Tech Conference Exhibitor ExperienceDuring the Conference1. Attendees approach booth2. Attendees look for swag

and then make eye contact

3. Exhibitor scans attendee badge (barcode, QR, NFC)

Page 6: Building Push Triggers for Logic Apps

After the Conference1. Data is retrieved from device in CSV format2. CSV file is emailed around3. CSV file is eventually imported into CRM system

Technical Conference Exhibitor Experience

Page 7: Building Push Triggers for Logic Apps

There must be a better way…

Page 8: Building Push Triggers for Logic Apps

Three Eras of Computing

Search and browse

Web pages

Know and doExperiences

Store and computeApplications

Page 9: Building Push Triggers for Logic Apps

Evolution of the Smart Fridge First Generation: Put a tablet in the

door Second Generation: No screen,

adds local device communication Generation of Integration: Sensors,

social, offers

Sample “Experience”

Your favorite sports team is playing tomorrow and you invited Alice and Bob over, would you like to get some more beer?

Yes.

Would you like a 6-pack or a full case?

Page 10: Building Push Triggers for Logic Apps

Two simple equations Internet of Things = Smart Things Internet of Things + Integration = Magic Things

What Happens When Integration Meets IoT?

Page 11: Building Push Triggers for Logic Apps

Logic Apps enable experiences

Page 12: Building Push Triggers for Logic Apps

Microsoft Azure App Service Logic Apps Framework for building and

running cloud-hosted workflows

Comprised of API Apps which provide behaviors and connections Think adapters and pipeline

components

What Are Logic Apps?

Page 13: Building Push Triggers for Logic Apps

During the Conference1. Attendees approach booth2. Attendees make eye contact3. Exhibitor scans attendee badge (barcode, QR, NFC)4. Scan data is sent to awaiting Logic App(s)5. Logic App(s) create leads in CRM system

Leads qualified/disqualified based on publicly available company data?

Targeted drip marketing campaign scheduled based on date/GPS coordinates scanned?

Technical Conference “Experience”

Page 14: Building Push Triggers for Logic Apps

Triggering a Logic App

Page 15: Building Push Triggers for Logic Apps

How Do Push Triggers Work?

Push Trigger API App

PUT

Logic AppCallback

URLNFC Tag

Read Phone App

Callback storage

Logic App registers for

callback with URL and credentials

As tags are read, stored callbacks

are executed

Page 16: Building Push Triggers for Logic Apps

Imagine that we’re building the Azure equivalent of a BizTalk Server Receive Adapter that receives data in an event-driven fashion.

You Lost Me, What Am I Looking At?

Page 17: Building Push Triggers for Logic Apps

Hello API App World

Page 18: Building Push Triggers for Logic Apps

Examining the Azure API App Template

Page 19: Building Push Triggers for Logic Apps

Routes Map inbound HTTP requests to methods that handle those

requests Defined through class/method-level attributes

Controllers Classes implementing API logic within methods designed to

handle incoming HTTP requests May derive from ApiController*

Models Classes that model the shape of API inputs/outputs

Key Components of a Web API Application

Page 20: Building Push Triggers for Logic Apps

Exploring the Swashbuckle Configuration

SwaggerConfig.cs Contains commented

documentation and sample code inline to guide you in emitting appropriate swagger metadata for your operations

Page 21: Building Push Triggers for Logic Apps

Logic App designer can natively consume Web APIs Cards will show all possible operations Operations and parameters may have unfriendly names Operations and parameters will lack meaningful

descriptionsMetadata can be added to API Apps to make them more friendly in the Logic Apps designer The T-Rex Metadata Library NuGet package can help

Exposing Functionality to Logic Apps

Page 22: Building Push Triggers for Logic Apps

Introducing the T-Rex Metadata LibraryT-Rex Provides .NET Attributes

Can be used to decorate methods/parameters with designer names and descriptions

Can be used to indicate triggers

T-Rex Provides Swashbuckle Filters

Swashbuckle filters change how swagger metadata is generated so that it includes data from .NET attributes

Source Code / Documentation https://github.com/nihaue/trex

NuGet Package http://www.nuget.org/packages/trex

Page 23: Building Push Triggers for Logic Apps

Implementing Triggers

Page 24: Building Push Triggers for Logic Apps

Special Considerations for Push Triggers Special metadata must be added to indicate a

given action is used for push callback registration T-Rex Metadata Library provides the Trigger attribute

triggerId string input is expected as first parameter of callback registration method Contains the name of the requesting Logic App by

default

Additional Steps Required for Building Triggers

Page 25: Building Push Triggers for Logic Apps

Special Considerations for Push Triggers TriggerInput<TInput, TOutput> is expected as

parameter of callback registration Logic App provides requested callback configuration

data through this parameter Logic App infers shape of incoming data through this

parameter

Additional Steps Required for Building Triggers

Page 26: Building Push Triggers for Logic Apps

Special Considerations for Push Triggers Callback registration method is expected to return

a specific response Azure App Service SDK provides

Request.PushTriggerRegistered extension method to assist

Additional Steps Required for Building Triggers

Page 27: Building Push Triggers for Logic Apps

using Microsoft.Azure.AppService.ApiApps.Service;using TRex.Metadata;

/* ... */

[Trigger(TriggerType.Push, typeof(SamplePushEventModel))][Metadata("Receive Simulated Push")][HttpPut, Route("{triggerId}")]public HttpResponseMessage RegisterCallback( string triggerId, [FromBody]TriggerInput<SamplePushConfig, SamplePushEventModel> parameters){

/* ... */}

Defining a Push Trigger Action Method

Trigger attribute causes metadata to be generated indicating that this is the callback registration method

for a push trigger

TriggerInput<TInput, TOutput> provides shape of the input expected on

the Logic App designer card, and shape out push trigger output

Page 28: Building Push Triggers for Logic Apps

// Notify the Logic App that the callback was registeredreturn Request.PushTriggerRegistered(parameters.GetCallback());

Responding That Push Trigger Callback Was Registered

PushTriggerRegistered extension method creates

appropriate HttpResponseMessage indicating

callback registration was successful

Page 29: Building Push Triggers for Logic Apps

Demo: Building an NFC Push Trigger

In this demonstration, you will see how to… Read data from an NFC card in a Universal

Windows App Implement a Push Trigger Invoke a Push Trigger Callback

Page 30: Building Push Triggers for Logic Apps

Your HomeworkPush-Button Push Trigger

Page 31: Building Push Triggers for Logic Apps

Push-Button Push Trigger for Logic AppsParts Required to Build

http://www.amazon.co.uk/dp/B00T2U7R7I

http://www.amazon.co.uk/dp/B00L2X1X9Q

http://www.amazon.co.uk/dp/B00KBXTO26

http://www.amazon.co.uk/dp/B00976KDBY

Sample Code http://bit.ly/1OOddFN

https://github.com/nihaue/PushButtonPushTrigger

Page 32: Building Push Triggers for Logic Apps

Demo: Push-Button Push Trigger in Action

In this demonstration, you will see… How to trigger a Logic App with the press of a

button

Page 33: Building Push Triggers for Logic Apps

Read the NFC Push Trigger Write-Up + Source Code http://bit.ly/1Myimgz

Attend the Hackathon This Weekend http://bit.ly/1Rjzo5N

Take a Class & Get Your Own Push-Button Push Trigger http://bit.ly/1RR7H5l

Stay Tuned for the Push-Button Push Trigger Write-Up http://bit.ly/1LjzWY5

What Now? Take a Photo of This Slide