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.
Benefits of Weebhook:
- 2-minute timeout
- Port usage limitation (only 80 & 443 allowed)
- We can’t use IP addresses, only named web addresses.
- heavy operations
How To use WebHooks in Crm Dynamics to post data from Plugin to Azure Function ?
1) create Azure function App in portal.azure.com: at first step we have to have account at azure side to host our function so it will be availble when we will call it from the crm dynamics system using the weebhook
2) Create Azure function App in Visual Studio :
Azure Functions application is availble starting from visual studio 2017 and i will recommened to use it because it help you so much to write your orgnised code in azure function otherwise you have to write every thing in azure side which will be not orgnised or hard to be orgnised and object oriented
We need here to choose a Http Trigger The HTTP trigger lets you invoke a function with anHTTP request. You can use an HTTP trigger to build serverless APIs and respond to webhooks. By default, an HTTP trigger returns HTTP 200 OK more about Trigger Here.
after creating the azure function app and then write your function code you need to deploy your code with azure function in additional words you need to configure connection between visual studio and
azure so first go to azure and download the publishing profile from
next step will be to add this profile which has been downloaded into visual studio
First Step to click right mouse on azure Project that you want to Publish
Then you will Get the publishing Console here we will add our profile by clicking new then upload the publishing profile
then upload your profile that you are already download it as we mention is step over
now the function will be availble on azure side so now we need to use plugin regestration tool to add a new WebHookto which will trigger our updates or create as we want
then choose whcih entity to trigger for example email we have to configure the step for updating or creating
finally we need to configurre the header of web hook . so what we need to do is configure the weebhook using plugin regestration tool
now copy the line and it will have two parte first one use it in web hook until the question mark
and add header like header key = x-functions-key
value copy it from the link in get function url it will be there as code = “ourcode”
after it when ever the email is created so the azure function will be called and there we could call our cognetive services more details will be followed in part 2