A Guide to Logic App Custom Connectors

08.31.17 By

Logic App connectors are the crucial components of Logic Apps, which is part of Azure Cloud Services. These connectors are used to enhance on-premises and cloud applications by enabling them to perform various data processes and integrate with other services.

Deployed and managed by Microsoft, these connectors provide quick access to events, data and actions across various protocols and services.

Logic App Connectors primarily fall in 4 categories:

  • Standard Connectors: These are available by default while using Azure Logic Apps.
  • Integration Account Connectors: These are available within an integration account. They can be used to transform and validate XML and process B2B messages with X12, AS2 or EDIFACT. These connectors are excellent to expand your BizTalk workflows to Azure.
  • Enterprise Connectors: These come at an additional cost. Examples include SAP and MQ.
  • Custom Connectors: These are used in cases where an API or service doesn’t have an associated or suitable connector but needs to be integrated, so a custom connector needs to be created.

Below is a list of widely used connectors:

  • HTTP
  • Azure Blob Storage
  • Azure Functions
  • Dynamics 365 CRM
  • SQL Server
  • SharePoint Online
  • Service Bus
  • Salesforce
  • FTP

Need for custom connectors

Azure Logic Apps includes more than 100 connectors. However, a custom connector may need to be created for certain scenarios, including:

  • Extending data integration workflows and current system integration
  • Expanding the use of your service
  • Helping customers use the service to manage varying tasks

Further, creating a custom API Logic App connector can help trace and debug errors associated with the logging of Logic Apps.

The steps below describe how to create a custom API and use it in the Logic App as a connector:

Step 1:

An API Model is created (Ex: LogEntry).

Connectors Create API Model

Next, a controller is created (Ex: LogicAppLogController) and then a method is added to it to log multiple errors, as there can be multiple errors at a time for different steps in the Logic App.

Connectors Log Multiple Errors

In the AddLogEntry method, if the log.Status = “Failed”, then the logs are added in the database table. You can use Log4Net to add the error logs in the database.

Then the SwaggerConfig file is added in the App_Start. To create a swagger file please refer the below mentioned URL.

https://docs.microsoft.com/en-us/azure/app-service-api/app-service-api-dotnet-get-started#use-swagger-api-metadata-and-ui

Step 2:

Azure Cloud services comprises features to assist in using API as a custom connector in the Logic App. It is deployed as a web app or API app to Azure app service. Also, the API definition properties are set and turned on cross-origin resource sharing (CORS) for your web app or API app to make your Swagger document readable by the Logic App Designer.

In the WebAPI, the API definition for the swagger file is set.

Connectors API Definition

In the WebAPI, the CORS policy for Allowed origins is set to ‘*’ (allow all).

Connectors CORS Policy

The swagger file will be visible as configured in the URL. In this case the swagger file can be found at “https://{WebAppName}.azurewebsites.net/swagger/docs/v1”

Step 3:

In this step, the Logic App in the Azure Portal is created. Use this example to utilize the Custom Logger API as a connector in Logic App:

Azure Logic App is created with a conditional check of finding a location from a list of locations. On the basis of the filtration connector, the next step will be executed, and if returned “true”, then it will call another API. If it fails, then it will execute the Custom Logger API connector, which will then add the log entries in the database.

A Logic App named CustomLogger is then created in any region and the Request trigger is added. If there is no input required in the next step, then it is saved with default JSON in the Request Body.

Connectors Saving with JSON

Then an action is added and variables action is selected and named as Locations.

Connectors Locations

Now a Condition is added for filtering the array data:

  • In case of YES, HTTP action is added, which will point to another Location API and fetch the result.
  • HTTP + Swagger action is added, in which you need to enter the swagger path (https ://{WebAppName}.azurewebsites.net/swagger/docs/v1) provided in Step 2. This will log the error in case of failure from the Location API Connector.
  • In case of NO, add another HTTP + Swagger action in which you will need to enter the same swagger path which you provided in Step 2.

Connectors Condition Added                                                      

IF YES

 Connectors Location API

Connectors Swagger Action

IF NO

Connectors 10.png

The above-mentioned steps describe the successful creation of a Custom API and description of how to use it as a Logic App as a connector. Logging errors and information in the database or system is one of the simplest use cases and one which most clients request in their Logic Apps. Custom connectors can be created as needed to get your data in the desired format.

Need help installing or managing Azure Cloud Services? Schedule a 15-minute call with our Azure Certified Experts.


By

Senior Systems Developer 
Email: ankit.shah@bridgenext.com



Topics: Product Design

Start your success story today.