Advertisements

Archive

Posts Tagged ‘WebHooks’

Dynamics 365 – Using WebHooks to post data from Plugin to Azure Function

July 15, 2018 2 comments

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’

wh1

  • Add below logic to Azure function which captures and logs the content posted from Plug-in

wh2

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

wh3

  • URL will have 3 parts
    • Endpoint URL
    • Code
    • ClientId
  • We would use only below 2 highlighted values while registering Plug-in.

wh4

Registering a WebHook:

  • Connect to Dynamics instance from Plug-in Registration tool
  • Click on ‘Register New Web Hook’

wh5

  • 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’

wh6

Register Plug-in Step on WebHook

  • Register a Plug-in step on WebHook assembly

wh7

  • Create a step on ‘PostAccountCreation’

wh8

Test the WebHook:

  • Create an Account from D365
  • Check the Logs in Azure Function’s ‘Logs’ tab

🙂

 

Advertisements
Categories: Azure, CRM Tags: , ,