Recently I needed to create an integration between a cloud platform and Dynamics 365 Customer Engagement Cloud. This Cloud Application (Unbounce) allows you to register Webhooks which you can use to send data across from that platform to any other web application.
Please note that this article already assumes that the reader understands the basics of Webhooks and Azure Functions.
Webhooks sends data when a server event occurs typically to a web application. They are lightweight HTTP pattern with a publish/subscribe model which sends POST requests with JSON payload. This means Webhook POST requests can be consumed by any programming language or web application anywhere.
So when our 3rd party Cloud application (for example Unbounce) sends out the webhook POST message, how can Dynamics 365 receive this POST message? The answer is: Azure Functions.
It’s not the first time that Microsoft Azure Serverless Inegration capabilities, namely Azure Function Apps, come to the rescue. Azure Functions are becoming more and more the default preferred option for many Dynamics 365 related integrations.
So Unbounce sends out the webhook POST message to the Azure Function which in turn sends this data to Dynamics 365. To do this, you need to create an Azure Function that is triggered by Webhook and in your function, you can write the code that sends Data to Dynamics 365. Below are 6 steps that show case the process for adding an Azure Function App triggered by a Webhook POST call. Please comment below if you require the code in the Azure funciton (It’s standard Dynamcis 365 call to create a field so nothing fancy).
1) First, create your Azure Function App:
Image may be NSFW.
Clik here to view.
2) Make sure that the function is triggered by Webhook + API and using C#:
Image may be NSFW.
Clik here to view.
3) Then once created, create a Function within your Function app
Image may be NSFW.
Clik here to view.4) Following that, we need to reference Dynamics 365 CRM SDK Core Assembly package. To do this, add a file called project.json as below:
Image may be NSFW.
Clik here to view.5) then input your code inside the run.cx function which will receive JSON POST message and writes it to Dynamics 365:
Image may be NSFW.
Clik here to view.6) then finally, run a test on your Azure Function App to see a record created in Dynamics 365 (a Lead in our case):
Image may be NSFW.
Clik here to view.
Please note that in step 5 above, you will definitely need to write code to receive the JSON payload that will come in the POST request message. So in our example, if this is coming from Unbounce, we have parse the Unbounce JSON data sent in the POST message so we can then use this data to create our lead (or contact) in Dynamics 365.
Please comment below if you require this code and I’ll be happy to share it.
Note: I’m delivering this session at a number of Dynamics 365 Saturday events starting tomorrow in London (7th July 2018). Hence, I’ll be updating it regularly (and apologies for rushing the post!)
Your feedback via comments below is invaluable and will encourage me to update it and write more about this subject.