Dynamics 365 – Using WebHooks to post data from Plugin to Azure Function
In my previous articles, I detailed the steps to create ‘Azure Functions’ and executing D365 SDK messages from ‘Azure Function’.
In this article, lets see how we fulfill Integration requirements using WebHooks model by submitting data to external WebAPIs and Services from D365.
What is a WebHook:
- Webhooks is a lightweight HTTP pattern for connecting Web APIs and services with a publish/subscribe model.
- Webhook senders notify receivers about events by making requests to receiver endpoints with some information about the events.
In this article, I am going to send data from Dynamics Plug-in to Azure Function using WebHooks model. So Plug-in acts as Webhook Sender and Azure Function acts as Receiver.
Below are the steps to create Azure Function and call Function from Plug-in by passing data.
Steps to create Azure Function:
- Refer Create Azure Function article to create Azure Function Apps.
- Create a new ‘Azure Function’ of type ‘Generic webhook’
- Add below logic to Azure function which captures and logs the content posted from Plug-in
Get Azure Function URL:
Copy the ‘Azure Function’ URL along with key which will be used to communicate from Plugin.
- Click on ‘Get function URL’ link and click ‘Copy’ to copy the URL
- URL will have 3 parts
- Endpoint URL
- Code
- ClientId
- We would use only below 2 highlighted values while registering Plug-in.
Registering a WebHook:
- Connect to Dynamics instance from Plug-in Registration tool
- Click on ‘Register New Web Hook’
- In the ‘WebHook Reistration’ page
- Set ‘Endpoint URL’ as the ‘Endpoint URL’ value copied from ‘Azure Function URL’
- Click ‘Add Property’
- Set ‘Key’ as ‘x-functions-key’
- Set ‘Values’ as ‘Code’ copied from ‘Azure Function URL’
Register Plug-in Step on WebHook
- Register a Plug-in step on WebHook assembly
- Create a step on ‘PostAccountCreation’
Test the WebHook:
- Create an Account from D365
- Check the Logs in Azure Function’s ‘Logs’ tab
🙂
-
August 30, 2018 at 6:12 PMIntegracja Dynamics 365 CE i Azure Functions – XRM Labs by Piotr Gaszewski
-
August 30, 2018 at 7:07 PMIntegracja Dynamics 365 CE i Azure Functions - Microsoft Dynamics CRM Community