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 6. Working with Connectors in Logic Apps

 

Insufficient facts always invite danger.

 
 --Mr. Spock, Star Trek

Azure Logic Apps is a cloud-based service that you can use to create workflows that run in the cloud. It provides a way to connect your applications, data, and SaaS application using a rich set of connectors. Connectors get data in and out of a Logic App. It is created specifically to help you when you are connecting to different data source or applications and working with your data.

In this chapter, you will learn the following topics:

  • What are the different types of connector available in Logic Apps?

  • What are Workflow Triggers and Actions?

  • How can we create our own custom connector?

Traditionally, the two of mainstream integration scenarios are as follows:

  • EAI (Enterprise Application Integration)

  • B2B (Business-to-Business) integration using EDI protocols, such as EDIFACT or ANSI X12

However, in today's world, many systems and users need to integrate with SaaS-based systems and API...

Categorizing Microsoft connectors


Connectors can be categorized into several groups based on the kind of operation they perform. These groups primarily include standard connectors and enterprise integration connectors.

Standard connectors

Standard connectors are the connectors created by Microsoft to work with SaaS applications or network services, and they include Office 365, SharePoint, Service Bus, Salesforce, SFTP, FTP/FTPS, and many more.

The following are the current list of available connectors created by Microsoft that are available as standard connectors. 

This list will keep growing. Please refer to the link: https://azure.microsoft.com/en-us/documentation/articles/apis-list/ for the latest list of standard connectors.

Some of these managed APIs can be used as is, such as Bing Translator, whereas others require configuration. This configuration is named a connection.

For example, when you use Office 365 connector, you need to create a connection that contains your sign-in token....

Types of triggers


The following six types of triggers are supported in Logic Apps as of now:

  • Recurrence trigger:This fires based on a defined recurring schedule—"every X second/minutes/hour/day".

  • HTTP  trigger: This polls an HTTP web endpoint for a response. Here, the connector as a trigger will either return 200 or 202 response.

    • A 200 response means "Run"—workflow will be executed

    • A 202 response means "Wait"—do not start the workflow as the connector does not have any response data to pass over to workflow

  • ApiConnection trigger: These are polls such as the HTTP trigger. However, it takes advantage of the Microsoft managed APIs (For more information refer to: https://azure.microsoft.com/documentation/articles/apis-list/). The basic functionality of API connection trigger is similar to the HTTP trigger.Here is an example of the Dropbox connector that polls a defined folder for a new file.

  • Manual trigger: This trigger serves as an endpoint that you call manually to invoke your Logic App...

Connector as an action


Each step after the trigger in a workflow is an action. Connectors can also be used as actions within your Logic Apps. Each action typically maps to an operation on your connector or custom API Apps that are defined in the Swagger metadata. Actions can have dependency, and they can be executed based on the condition such as success or failure of the previous action.

You can use the action for variety of operations such as to look up customer data from a SQL database when processing an order or may be to write, update, or delete data in a destination table.

Actions can be categorized as Standard Action and Collection Action.

Standard Actions:

There are six valid types of standard actions, each with unique behavior.

  • HTTP: This action calls an HTTP web endpoint.

  • ApiConnection: This action has behavior similar to the HTTP action; however, it takes advantage of the Microsoft-managed APIs. Here is a Dropbox action to create a file in the specified folder.

  • ApiConnectionWebhook...

Building your first connector


As discussed in the beginning of this chapter, a connector is basically an API app that focuses on connectivity and gets data in and out of Logic Apps. In this section, we will try to build an Azure Storage Table connector. At the time of writing this chapter, Azure Storage Table connector was not available in the marketplace.

Azure Storage Table connector

We are building this connector to pull author or chapter details for this book from a Book Entity in the storage table.

First of all, we will create the API App project for storage table connector. Please follow the steps described to create an API App in Chapter 3Getting Started with API Apps.

API App project will have a BookEntity model and a controller BookController as shown here:

BookController will have an operation GetBookEntity. This operation primarily takes the PartitionKey and the RowKey to fetch the record from the storage table. If you see the model, the author or the chapter is the partition...

Make your connector work for Logic Apps


Now when we try to use this API App as a custom connector in Logic Apps, there are certain gaps that we will cover now. First of all, we need to enable the CORS setting for the API App (AzureStorageTableConnector) we have created. Add a CORS policy for * to allow the requests from the Logic Apps Designer. Please refer to Chapter 3, Getting Started with API Apps, for understanding CORS.

We have created an empty Logic App in the portal where we select the custom connector – AzureStorageTableConnector. Once you have enabled the CORS, you would be able to see the AzureStorageTableConnector in custom connector list in Logics App.

Once you select the AzureStorageTableConnector in the Logic App, you can see the get operation with input parameters AUTHORORCHAPTER and SEQUENCENUMBER as shown later. And if you select the next connector in the Logic App (for example, I have selected the Dropbox connector), it shows all the outputs from the GetBookEntity operation...

Adding summary and XML Documentation


First, we need to turn on the generation of XML documentation in the Build properties page of API App project.

Now uncomment the line that tells Swasbuckle to include XML comments in the Swagger.cs file.

You now need to implement the function GetXMLCommentsPath() that would return the XMLComment file for the API.

Now if you run the project, you can see the following in the Swagger UI. Now you can see the summary for API and description for parameters as shown here:

Discovering partion keys in the storage table


One more thing if you note here is that when we use the AzureStorageTableConnector, it asks us for the partion key that can have only two values in our scenario, either author or chapter. It would be nice if our custom connector can go to storage table and find all the partion keys available and then may be provide it as a drop-down so that we can select the partion key instead of entering the value. This can be done using dynamic Swagger to enhance user experience. Swagger dynamically generates metadata depending on API App configuration.

To do this, you need to add a filter, as follows:

In the filter implementation, it looks for the parameter authorOrChapter , and if it finds the parameter, it will add it as an enumeration, which means the authorOrChapter parameter can take all the partition keys (author and chapter) as the enumeration value. To add the partition keys to enum, we have the method GetPartionKeys that abstracts how you get all...

Summary


In this chapter, we discussed about the Logic App Connectors, which are basically API Apps that focus on connectivity. We looked into different types of connector currently available in Logic Apps to build your business process workflows.

We also discussed about triggers and actions and their different types. Finally, we created custom connector to pull records from the Azure Storage Table. We used the custom connector to create a Logic App workflow, which can be invoked using an endpoint. We tested the Logic App using the tool Postman.

In the next chapter, we will understand Azure function and how it can be used in Logic Apps.

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