Configure Dynamics 365 and Azure Service Bus Integration

As we know, we can connect Dynamics 365 with Azure platform by coupling Dynamics 365 event execution pipeline to the Microsoft Azure Service Bus. Once configured, this connection allows data that’s been processed as current Dynamics 365 operation to be posted to the service. Microsoft Azure Service Bus solutions that are “Dynamics-365 aware” can listen for and read the Dynamics 365 data from the service bus.There are many ways to establish a contract between Dynamics 365 and an Azure solution as below.

  • Queue
  • One-way
  • Two-way
  • Rest
  • Topic
  • Event Hub

In this post, I will use “Queue” contract where a listener doesn’t have to be actively listening for messages on the endpoint.
Let’s implement a basic scenario – When a record is created in CRM then pass the execution context to queue and then prepare a application to read and display the entity information.

Lets first configure Azure to create a Queue listener using Azure Portal(https://portal.azure.com).

  1. Create a Service Bus by click on “Add” button.

    2. Enter mandatory fields as below.

3. Create a Queue in newly created Service Bus(mcstaging in my case)

4. Create SAS Policy for Authorization and copy the Primary Connection String which is required during end point registration in CRM

Now let’s create service endpoint in CRM using plugin registration tool.
Login into plugin registration tool and click on Register ->Register New Service End Point as below


Copy the primary connection string form  step 4 and click on “Next”

All information will be populated automatically and then click on “Save”.
Now, need to register a step for this endpoint(In my case, custom entity Enquiry(mc_feedback)  on create message).


Now create a enquiry record in CRM, once you create a record in CRM a system job will be created and message will be passed to azure queue created earlier.

You can see one message in queue as below


Now, how to read the message from Queue. Lets create a console application to read the message from Queue.
Here the connection string will be the same which we had specified in the plugin registration tool. The message body is of type RemoteExecutionContext.


Output

 

Author: Arvind Singh

Solution Architect with 15+ years of exp. Dynamics CRM, Power Platform, Azure which includes Solution, Design, Development, Deployment, Maintenance and support experience.

One thought on “Configure Dynamics 365 and Azure Service Bus Integration”

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

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

Facebook photo

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

Connecting to %s

%d bloggers like this: