“Register a New WebHook” through Plugin Registration Tool in Dynamics 365

With July 2017 Update, now we have the option to register a new Webhook through Plugin Registration tool.

Download the latest Plugin Registration Tool from NuGet using the PowerShell script à


Through registering a Webhook, we can send data (execution context) about any operation performed on Dynamics 365 to the external services or application. The execution context information is passed in JSON format here.

More details here


Let us take a simple scenario to see it in action.

First will create an Azure Webhook which passes the Execution Context to the Azure Service Bus Queue. We will also create a sample Queue Listener application that parses and reads the information from the queue.

  • Create a new Function of type Webhook + API (CSharp).

  • Select Integrate in the newly created function and click on New Output button and add Azure Service Bus as an output.

  • Specify Message type as Service Bus Queue and other required values like Service Bus Connection, Queue Name and the parameter name and click on Save.
  • Update the code for our function to pass the execution context information to the queue
  • Now let us register our Webhook inside Dynamics 365. For this copy the function URL using Get function URL button.

  • Click on Copy.

  • Inside Plugin Registration tool, click on Register à Register New Web Hook.

  • Specify any Name for the Webhook. In the Endpoint URL, paste the URL copied without any query string part. For Authentication select WebhookKey and paste the “code” query string value to register the Webhook.

  • Register a new step of Lead Create to it.

  • After registering the step, to test our Webhook Function, let us create a new lead record inside Dynamics 365.

  • Back in our function, click on Monitor to check the log. There we can see the execution context information passed to our function.

  • Inside the Queue specified as Output of the function, we can see the new messages added.

  • Below is the sample code to read the message from the queue.

private static void QueueClientExample()
// create a new Shared Access Policy for the queue
// set the connection string of the Shared Access Policy created
var connectionString = "Endpoint=sb://[namespace].servicebus.windows.net/;SharedAccessKeyName=MyPolicy;SharedAccessKey=[KeyValue];EntityPath=mycrmqueue";

// create the Queue Client object
var client = QueueClient.CreateFromConnectionString(connectionString);

// get the message from the Queue Client
BrokeredMessage brokeredMessage = client.Receive();

var stream = brokeredMessage.GetBody<Stream>();
StreamReader streamReader = new StreamReader(stream);
string jsonData = streamReader.ReadToEnd();
jsonData = jsonData.Replace(@"\", string.Empty).Trim(new char[] { '\"' });
JObject context = JObject.Parse(jsonData);

Console.WriteLine("Primary Entity Name = " + context["PrimaryEntityName"] + " Message Name = " + context["MessageName"]);


  • The output

More on Azure Functions à


Similar example using Azure Service Bus Integration à


Hope it helps..

Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

5 thoughts on ““Register a New WebHook” through Plugin Registration Tool in Dynamics 365”

  1. Hi Nishant, thanks for this post.

    Just wondering what are the benefits using Webhooks + Azure Functions, instead of using just Service Endpoints in CRM (sending the execution context to a queue/topic in the Service Bus)? Is not the same thing just with extra steps?


  2. Good question. This nicely explains it Felipe

    When deciding between the webhook model and the Azure Service Bus integration, here are some items to keep in mind:

    Azure Service Bus works for high scale processing, and provides a full queueing mechanism if Dynamics 365 is pushing many events.
    Webhooks can only scale to the point at which your hosted web service can handle the messages.
    Webhooks enables synchronous and asynchronous steps. Azure Service Bus only allows for asynchronous steps.
    Webhooks send POST requests with JSON payload and can be consumed by any programming language or web application hosted anywhere.
    Both webhooks and Azure Service Bus can be invoked from a plugin or custom workflow activity.



  3. Hello Nishant

    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?


  4. Hi

    Interesting post as web hook endpoint can also be used to trigger an MS Power Automate flow.
    However, as for any service endpoint I am wondering how you deploy this stuff.
    The service endpoint url seems to be part of the deployment, but in DTAP scenario also the endpoint will differ per type of environment?

    Kind regards



Please share your thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.