Reader small image

You're reading from  Robust Cloud Integration with Azure

Product typeBook
Published inMar 2017
Reading LevelIntermediate
PublisherPackt
ISBN-139781786465573
Edition1st Edition
Languages
Tools
Right arrow
Authors (6):
Ashish Bhambhani
Ashish Bhambhani
author image
Ashish Bhambhani

Ashish Bhambhani is an Integration Sr. Premier Field Engineer working for Microsoft. He lives in the Seattle region. He has been working in the integration space for more than a decade. In his current role he helps Microsofts enterprise customers by architecting, designing, building, and maintaining their integration solutions. Recently, he has been able to roll out Azure technologies enterprise-wide for his clients and replace their legacy solutions. He is a content creator and master trainer for some of a Microsofts training that is delivered to clients worldwide. Additionally, he was part of the team that wrote the BizTalk performance whitepaper for msdn.com
Read more about Ashish Bhambhani

Abhishek Kumar
Abhishek Kumar
author image
Abhishek Kumar

Abhishek Kumar works with New Zealand Trade and Enterprise as an integration and data specialist. He is a Microsoft Azure MVP with deep expertise in software development and design. He is a co-author of Robust Cloud Integration and a seasoned contributor to Microsoft blogs, forums, and events. As a technological evangelist, he is specialized in cloud-based technologies such as Azure Functions, Microsoft Graph, Logic Apps, Web API, and Cosmos DB, along with various Software-as-a-Service (SaaS) such as Salesforce, Office 365, and ServiceNow. As a technology advocate, he promotes loosely coupled solution design along with event-based programming.
Read more about Abhishek Kumar

James Corbould
James Corbould
author image
James Corbould

James Corbould has been working in the IT sector since 2003, developing and supporting applications in New Zealand and the United Kingdom. Since 2010, James has been working in the software integration field, designing and building integration solutions using Microsoft technologies such as BizTalk, SQL Server, WCF, .NET, and now Azure, for a wide range of different customers. Recently, he has been working in the health insurance sector and in the building supplies sector.James currently works for Datacom Systems as a consultant and team lead.
Read more about James Corbould

Mahindra Morar
Mahindra Morar
author image
Mahindra Morar

Mahindra Morar has been working in the IT sector from 1997, developing Windows and website enterprise applications. In 2009, he has been focusing primarily on integrating systems as a principle integration consultant. Having come from an electronics engineering background, he is able to use this knowledge to design solutions that integrate between wetware, software and hardware.
Read more about Mahindra Morar

Martin Abbott
Martin Abbott
author image
Martin Abbott

Martin Abbott is a Microsoft Azure MVP living in Perth, Western Australia. He started his career developing subroutines for commercial computational fluid dynamics software, eventually moving on to more mainstream development and systems integration. He has been working with BizTalk Server since the early days of the product, has spent a lot of time with WCF, but more recently has moved in to providing his customers with integration solutions spanning both on-premises and cloud workloads.
Read more about Martin Abbott

View More author details
Right arrow

Chapter 8. A Deep Dive into Logic Apps

 

Logic is the beginning of wisdom; not the end

 
 --Spock Star Trek

In previous chapters, we discussed how to automate business process with Azure Logic Apps and its different concepts such as workflow, connectors, trigger, and actions. In this chapter, we will dive deep into Azure Logic Apps by creating a complex business workflow using features such as control flow, looping, and exception handling. We will look at the Logic Apps code view and play around with the workflow definition language. We will explore the ability to call nested Logic Apps directly from Logic Apps designer.

This chapter introduces the following topics:

  • Workflow definition language

  • Content type in Logic Apps

  • Logic Apps loops, scopes, and SplitOn

  • Exception handling in Logic Apps

  • How to build a complex workflow using on-premise data gateway for Logic Apps

Azure Logic Apps provide a new way to automate business processes and running them in reliable way in cloud. Anyone who can use Azure...

Workflow definition language


The workflow definition contains the actual business logic that is defined as part of the Logic Apps built. Workflow definition language is described thoroughly over Microsoft documentation: https://docs.microsoft.com/en-us/rest/api/logic/definition-language.

The basic structure of workflow definition Language is as follows:

{ 
      "$schema": "<schema-of the-definition>", 
      "contentVersion": "<version-number-of-definition>", 
      "parameters": { <parameter-definitions-of-definition> }, 
      "triggers": [ { <definition-of-flow-triggers> } ], 
      "actions": [ { <definition-of-flow-actions> } ], 
      "outputs": { <output-of-definition> }     
} 

Parameters


Parameters are place holders to keep the values that are subject to change. For example, if you have a different URL property for an API App hosted for development, test, and production, then it is viable to have a parameter defined that we can change at deployment time.

The basic structure for parameters is shown here:

"parameters": { 
 "<parameter-name>" : { 
    "type" : "<type-of-parameter-value>", 
    "defaultValue": <default-value-of-parameter>, 
    "allowedValues": [ <array-of-allowed-values> ], 
    "metadata" : { "key": { "name": "value"} } 
  } 
} 

Here is the code view where we have a parameter named useremail within the parameters section:

Once the parameters are defined, we can use them within Logic App workflow repetitively using workflow expression language.

Output


In Azure Logic Apps, if you have a particular status or value in your Logic App workflow that you want to track for each run, you can define that within run output section and it will appear in the Management REST API for that run, and in the management UI for that run in the Azure Portal.

Outputs are not used to respond the caller service. To respond to an incoming request response, action type should be used.

The basic structure for parameters is shown here:

"outputs": { 
  "key1": { 
    "value": "value1", 
    "type" : "<type-of-value>" 
  } 
} 
  • key1: Specifies the key identifier for the output. Replace key1 with a name that you want to use to identify the output.

  • value1: Specifies the value of the output.

  • <type-of-value>: Specifies the type for the value that was specified. The possible types of values are:

    • string

    • secure string

    • int

    • bool

    • array

    • object

    • Expression, operators and functions

You can execute expressions including operators and functions...

Content type in Logic Apps


Content type defines the actual format of the data that flows through system. Logic Apps engine can process multiple content types, such as JSON, XML, Flat Files, and binary data. There are some natively supported content type for Logic App workflow engines such as JSON, Text, and XML, and other requires casting from one format to another.

Content-Type header

The Content-Type header is used to specify the nature of the data in the body of an entity, by giving type and subtype identifiers, and by providing auxiliary information that may be required for certain types. When a client posts a request to the server and specifies the content type, it makes easy for the server to understand the data and parse it.

These are the basic Content-Type, we use within a Logic App.

  • text/plain

  • application/json

  • application/xml

Text/plain

The text Content-Type is intended to send data that is principally textual in form. The primary subtype of text is plain. This indicates the plain (unformatted...

Flow controls, SplitOn, and scope in Logic Apps


Integration solutions are complex to build where we need to communicate with multiple systems and devices and follow different design patterns based on application requirement. When we develop integration solution, we are not confined to the same architecture design, but we use combination of multiples patterns for our solutions.

For each loop

In Logic Apps, you can use the add a For each action to iterate over an array item and perform the action or set of actions on each item.

To demonstrate the use case of the add a For each action, here is a simple Logic App that gets a list of new products from HTTP request and Logic App iterate through individual product in the array and send a notification mail to inventory.

We have used a single trigger and an action that is send the email. You can have multiple actions associated with your add a For each action, which can perform a necessary action based on your workflow design. To get deep understanding...

Exception handling in Logic Apps


It is always advisable to have good exception handling mechanism in place before you start implementing any business flow using Logic Apps. Logic Apps provide a robust way to handle exception within the workflow, and later sections are dedicated with some common ways to do exception handling if the workflow do not go with happy design flow.

You can get more information on Microsoft documentation shared in the following links:

Scopes to catch failures

As discussed in the previous section, the scope allows you to group actions together. So, it primarily acts as a logical grouping of actions, which is useful for organizing your logic app actions and for performing aggregate evaluations on the status of a scope.

The scope itself has its own status, which it receives...

Summary


In this chapter, we started with workflow definition language for Logic Apps including expressions, operators, and functions. The workflow definition contains the actual logic that gets executed within the Logic App engine. The workflow definition is a JSON file that contains a one or more triggers that initiate the Logic App and associated single or multiple actions within the Logic App. We also looked into the types of header content supported in Logic Apps and how can we loop through the array items in the message using flow control - foreach, until, and Terminate. We also discussed how to implement exception handling using scope in Logic Apps.

Finally, we covered the hybrid integration scenario using On-premise data gateway, where Logic App connects securely to on-premise SQL server to insert records in database tables. We also created a nested workflow where once Logic App calls another to achieve a composite service-type workflow.

In the next chapter, we will introduce SaaS connectivity...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Robust Cloud Integration with Azure
Published in: Mar 2017Publisher: PacktISBN-13: 9781786465573
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (6)

author image
Ashish Bhambhani

Ashish Bhambhani is an Integration Sr. Premier Field Engineer working for Microsoft. He lives in the Seattle region. He has been working in the integration space for more than a decade. In his current role he helps Microsofts enterprise customers by architecting, designing, building, and maintaining their integration solutions. Recently, he has been able to roll out Azure technologies enterprise-wide for his clients and replace their legacy solutions. He is a content creator and master trainer for some of a Microsofts training that is delivered to clients worldwide. Additionally, he was part of the team that wrote the BizTalk performance whitepaper for msdn.com
Read more about Ashish Bhambhani

author image
Abhishek Kumar

Abhishek Kumar works with New Zealand Trade and Enterprise as an integration and data specialist. He is a Microsoft Azure MVP with deep expertise in software development and design. He is a co-author of Robust Cloud Integration and a seasoned contributor to Microsoft blogs, forums, and events. As a technological evangelist, he is specialized in cloud-based technologies such as Azure Functions, Microsoft Graph, Logic Apps, Web API, and Cosmos DB, along with various Software-as-a-Service (SaaS) such as Salesforce, Office 365, and ServiceNow. As a technology advocate, he promotes loosely coupled solution design along with event-based programming.
Read more about Abhishek Kumar

author image
James Corbould

James Corbould has been working in the IT sector since 2003, developing and supporting applications in New Zealand and the United Kingdom. Since 2010, James has been working in the software integration field, designing and building integration solutions using Microsoft technologies such as BizTalk, SQL Server, WCF, .NET, and now Azure, for a wide range of different customers. Recently, he has been working in the health insurance sector and in the building supplies sector.James currently works for Datacom Systems as a consultant and team lead.
Read more about James Corbould

author image
Mahindra Morar

Mahindra Morar has been working in the IT sector from 1997, developing Windows and website enterprise applications. In 2009, he has been focusing primarily on integrating systems as a principle integration consultant. Having come from an electronics engineering background, he is able to use this knowledge to design solutions that integrate between wetware, software and hardware.
Read more about Mahindra Morar

author image
Martin Abbott

Martin Abbott is a Microsoft Azure MVP living in Perth, Western Australia. He started his career developing subroutines for commercial computational fluid dynamics software, eventually moving on to more mainstream development and systems integration. He has been working with BizTalk Server since the early days of the product, has spent a lot of time with WCF, but more recently has moved in to providing his customers with integration solutions spanning both on-premises and cloud workloads.
Read more about Martin Abbott

Element name

Description

$schema

This specifies the location of the JSON schema file that is used for workflow definition language. This is required when you reference a definition externally.

contentVersion

This specifies...