Oct 9, 2017

Synchronize Contacts to a Table Using Azure Logic Apps

I have suggested few ways of getting free Azure Subscriptions for Dynamics 365 developers through a post. Click here to read that.

Now though of jumping in to Azure Logic Apps, among many new Dynamics 365 + Azure technologies.

Azure Logic Apps come in handy in integrating Dynamics 365 with many third-party applications. Anyway, most fundamental requirement could be to synchronize an entity data with a SQL database. Below step-by-step guide is to illustrate how we can achieve this in a simple manner.

Let’s open a logic app in Azure. Click New, Select Web + Mobile and select Logic App.


 Now give a meaningful name to the Logic App and Create a Resource group or select existing one.


Then you will come to Logic App Designer with all kinds of Templates. Still I prefer to use a Blank Template for the sake of learning and flexibility. Click Blank Template and select Dynamics 365 as the Connector as below.


Within many triggers, select Dynamics 365 – When record is created or updated as the trigger.



Obviously, you need to provide your Dynamics 365 Organization and Entity interested in synchronizing. In my scenario, it’s Contact.


Now add the Condition which does the trick. In Dynamics 365, we have selected the trigger which tracks both Create and Update operations. You may notice we don’t have such single operation in SQL. Our approach is to check if Created on equals Modified On. If Condition satisfies, it’s a Create or else an Update.


Now add SQL server Insert row action if condition is satisfied and match the table fields with Dynamics 365 fields as below. I have selected only few fields here, but it’s essential to map Id column so Dynamics and SQL table record can be mapped for Update Operation.


Now add SQL server Update row action if condition is NOT satisfied and match the table fields with Dynamics 365 fields as below. You will notice we have extra field called Row id here which is nothing but the Primary Key. This is obviously necessary for Updating.


Now run the logic App and try the operation.

I created Contact record for Mark Wilkinson, and I got below record created through Logic App. App identified this as a Create operation since both Created On and Modified On values are same.


Then I changed the Description field and found it’s correctly updating the record as below.


This is just simple explanation, but this is evident Logic Apps can be used to synchronize Dynamics 365 data with SQL tables easily.

No comments:

Post a Comment