Creating Azure Logic App for Salesforce Integration

Author - Varun Chopra
12.09.2018
|
0 Comments
||

Introduction to Azure Logic Apps | Creating Logic App for Salesforce Integration

Azure App Services

Azure App Services is an integrated service which allows to create web and mobile applications from any platform or for any device. This includes Logic Apps and API apps capabilities along with built in connectors which allows us to integrate with Saas (Salesforce, Dynamics CRM etc.) and on premise applications (Oracle, Facebook, twitter etc).

Azure App services may integrate different type of apps which can be:

1. Web Apps
2. Mobile Apps
3. Logic Apps
4. API apps

Azure App Service enables you to easily create Web + Mobile + Logic + API Apps:

Web Apps: -> We can create web applications inside Azure App service platform as we used to build azure websites previously. They provide similar functionalities and flexibilities.

Mobile Apps:-> We can create mobile applications inside Azure App service platform as we used to build azure mobile applications previously. We can create web+mobile application within this platform instead of creating them differently. They both can use the same backend and we can manage our resources in a better way.

Logic Apps:-> The Logic App enables you to automate workflows and business processes. Logic apps are like workflows that can run on any API call, update record action or on specific time. You can create logic app using json file or Logic App designer available in this platform. Within the workflow, you can update or retrieve records from Saas applications, post a message on Facebook or Twitter etc. Azure App services provide various built in connectors that can be used to create or automate your Logic App workflows.

API Apps:-> API apps allows us to call or consume API calls within this platform including both APIs you create (using a framework like ASP.NET Web API or the equivalent in other languages) as well as APIs from other SaaS and cloud providers. We can optionally integrate these APIs with Logic Apps.

Logic Apps

Logic Apps are designer-first integration services that can create workflows. They integrate with various SaaS and enterprise applications. Azure Logic Apps and Functions are the backbone of serverless architecture in Azure. They both allow developers to quickly create and deploy code to the cloud that needs to be scalable, lightweight and fast.

Components of Logic Apps

LogicApps consist of four components; connectors, triggers, conditions and actions.

Connectors:-> Connectors allow us to connect to the services. These are the code blocks coupled together to connect to service. Each connector has its own API and needs credentials for accessing the service.

Triggers: -> Triggers are used with connectors to initiate your workflow. Each API provide related triggers. You can select based on your requirement.

Actions:-> Actions are the steps in the workflow. Each trigger, condition and function are considered as actions. Action is the task that we do with the input received from the connector. Like Sending mail, updating the salesforce records etc.

Conditions:-> Conditions are optional. You can use any conditional loops like foreach, if else, do until etc. These are used to insert some logic into your workflow.

You can create logic Apps directly on Azure portal or can be created using visual studio 2015 or later.

Creation of Logic App

Here I am creating a logic app for the integration between Salesforce and My azure Database. I have created few tables in my Azure database out of which two are Contacts and Accounts table. Following screenshot will show the DB design of these two tables.

Salesforce Integration

Now, we will create the logic app. Login into azure portal. Click on Create a resource -> Web -> Logic App as shown in following screenshot.

Salesforce Integration

Now, When we click on Logic App, following screen will appear.

Salesforce Integration

Add required details for app name, subscription, location etc. as shown above and click on create button. “Deployment is in progress” message will start showing in the Notification area. After 1 or 2 minutes when deployment will be successful, following screen will appear.

Salesforce Integration

Click on ‘Go To Resource’ button to enter your application area in portal, where you will be able to see your application related information, settings and actions etc. as shown below. At the top of the screen in the Overview section, click on the logic App name link to see the UI of logic App.

Salesforce Integration

First Screen that will be shown to us in Logic APP is its designer. Following screenshot is showing the Logic App designer.

Salesforce Integration

Logic App always starts with a trigger. You can also see some default triggers provided by Azure. If you want to implement your custom trigger, click on Blank Logic App template and following options will appear.

Salesforce Integration

First, List of various supported connectors will appear. When you click on your required connector, it will ask you to login to your account on that connector so that you can connect with that application. In our case, we will select the salesforce connector and it will ask us for salesforce credentials. After successfully login to our salesforce account, it will show us salesforce supported triggers (like ‘When a record is created’ and ‘When a record is modified’) as follows:

Salesforce Integration

Now, as per your requirement, select appropriate trigger. I have selected the ‘Create’ trigger and then it will ask for details like ‘trigger will work on which salesforce object and interval’, ‘when this trigger will run?’ etc. as shown in following screenshot.

Salesforce Integration

Then, we can add new step in our workflow which gives us options like ‘Add an action’ or ‘Add a condition’ etc. Now, users can add any conditions. I have added condition – ‘if email of contact contains “banita” then it will add the contact in my azure database otherwise it will do nothing’.

Salesforce Integration

If my condition is true, I want to insert the row in SQL DB. So, In ‘if true’ condition, Choose an action, select the connector first i.e. on which application you want to connect and perform the action (which is SQL Server in our case). Then, choose the action as shown in following screenshot.

Salesforce Integration

Select the Insert row action and add the required details as shown below

Salesforce Integration

Now, my workflow is complete. You can add any number of conditions and actions in one workflow. As workflow always starts with trigger. So, you need to create the logic app per trigger. You can not add multiple disconnected triggers in one workflow.

Salesforce Integration

Now, Save your Logic App and click on Run button shown in above screenshot.

Now, our trigger starts with creating the contact in salesforce account. So, create the Contact in salesforce. I have created the Contact but did not provided the email in that Contact then following error appears when our workflow executes.

Salesforce Integration

Workflows shows the error details. As we can see in the screenshot, our condition is not running properly as specified in the error details. Next time, I provided the correct email and saved the record again, another error came as shown in the following screenshot.

Salesforce Integration

I have created the AccountID as foreign key in our Contact table. Currently, In my database, there is only one account ‘BJSolutions’ and I have provided the different account in the Contact details So, workflow shows the above error.

Now, I have provided all the correct details as shown below.

Salesforce Integration

Workflow executed successfully this time as shown below

Salesforce Integration

Now, we need to check in our DB whether this contact information is inserted in our DB or not. Details of contact is added successfully in our Azure DB as shown below

Salesforce Integration

You can check the Status of your Logic APP in the overview page of you logic App like how many times it ran. You can further check the details related to each time it ran as shown in the screenshot below.

Salesforce Integration

Click on the row for which you want to check the details as shown below:

Salesforce Integration

Click on Run details button shown in the top header and further details related to this run will be shown as follows:

Salesforce Integration

Logic App is created per trigger. And you can create as many logic apps as required.

Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at dev@webners.com for your Insurance, eLearning and Salesforce applications.

Leave a Reply

Your email address will not be published. Required fields are marked *