Dynamics 365 - Register a Webhook using Plug-in Registration tool with Azure Function
Starting with Dynamics 365 (online), version 9.0 you can send data about events that occur on Dynamic 365 to the external services or application using webhooks. Webhook senders notify receivers about events by making requests to receiver endpoints with some information about the events.
Use the Plug-in Registration tool to register a webhook. Download the latest Plug-in registration tool from Nuget, see Download tools from Nuget
Simple example to see it in action from end to end.
I will create an Azure Function which sends the execution context to an integrated Azure service bus output. The Azure function web hook will be register in CRM using the “Register New Web Hook” option.
- Create new Function App
- Create new Function of type Webhook + API and choose CSharp as language.
- Rename the function name using kudu console and select Integrate in the function and click on New Output button and add Azure Service Bus as an output.
- Specify Message type as “Service Bus Queue”, Queue Name as “CRMEntityQueue” and Service Bus Connection. Service bus connection is name of the app setting contacting your service bus connection string.
- Update the code for CreateContactsTrigger function to pass the execution context information to the CRMEntityQueue and write logs for testing.
- Now will register the WebHook function in Dynamics 365. Copy the function URL using Get function URL button.
- Click on Copy to get the web hook endpoint URL.
- Now we will register the web hook using Plugin Registration tool. Click on Register and “Register New Web Hook”.
- Specify any Name for the Webhook. In the Endpoint URL, paste the URL copied without any query string. For Authentication select WebhookKey and paste the “code” query string value to register the Webhook.
- Now register a new step of create contact .
- All registration completed now. To test the webhook function, we will create a new contact record in Dynamics 365.
- Now we will verify the response. Back to azure, to monitor the function logs and azure service bus queue entry. Click on monitor.
- Inside the Queue specified as Output of the function, we can see the new messages added.
Hope this example helps to use the new features for registering webhook .
Hello Satya, What is the method of receiving response back to the CRM plugin or workflow? I am working on a scenario where I sent the plugin context to the function but I would expect the response of the function will set entity attributes in return. Can you guide me how this can be done?
Thanks for amazing article
Wish to see many more articles from you.