Building Push Triggers for Logic Apps
-
Upload
biztalk360 -
Category
Technology
-
view
1.074 -
download
0
Transcript of 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
Building Push Triggers for Logic AppsNick HauensteinMicrosoft Integration MVPPrincipal Software Development Engineer, QuickLearn Training@nickhauenstein
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:
Let’s start with a story…
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)
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
There must be a better way…
Three Eras of Computing
Search and browse
Web pages
Know and doExperiences
Store and computeApplications
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?
Two simple equations Internet of Things = Smart Things Internet of Things + Integration = Magic Things
What Happens When Integration Meets IoT?
Logic Apps enable experiences
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?
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”
Triggering a Logic App
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
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?
Hello API App World
Examining the Azure API App Template
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
Exploring the Swashbuckle Configuration
SwaggerConfig.cs Contains commented
documentation and sample code inline to guide you in emitting appropriate swagger metadata for your operations
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
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
Implementing Triggers
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
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
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
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
// 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
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
Your HomeworkPush-Button Push Trigger
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
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
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