Integrating with Microsoft Dynamics 365 CE

Rayyan Rashid | April 3, 2023 

Integrating with Microsoft Dynamics 365 CE (CRM) using a service bus.

A client’s business objectives is to integrate their e-commerce platform with Microsoft Dynamics 365 CE (CRM). One of the goals of this integration was to create an account on the CRM or update if it already existed. As described in the use cases below, we used an Azure Service Bus to receive messages from the client in a JSON format and send the message through an Azure Logic App to meet our objective.

What is an Azure Service Bus?

Azure Service Bus is a service offered by Microsoft Azure that is capable of enterprise level messaging capabilities.  This can be used to enable applications and services to communicate with each other using a queue-based messaging system.  Some common use-cases for services buses are as follows:

Building secure messaging systems to transfer data for an enterprise,

Decouple applications to improve reliability and scalability,

Automating workflows to run when certain events are used as triggers, and

Integration of cloud-based applications by acting as a medium to transform and transfer messages in a controlled manner. 

What is an Azure Logic App?

Azure Logic App is a cloud-based service provided by Microsoft Azure that allows users to create and run automated workflows or integrations. It comes with a variety of connectors that can be dragged and dropped to create workflows that interact with other Azure services or third party applications.

A typical Logic App Workflow runs when a trigger is set off. In our case, the trigger is whenever we receive a message in our Service Bus Queue. We then parse this message and transform the data to obtain what we need, after which we interact with the Microsoft Dataverse to obtain and create what we need.

How to Send Messages to an Azure Service Bus?

I needed a way to send JSON messages similar to what we expected from our client in order to test the service bus and logic app and ensure all requirements are met.  The following code snippet shows us how we can accomplish this:

We start by creating a JSON message similar to the format expected by the client.  A client reference for our service bus is created and then a sender to push the message onto the queue.  Shown below, batches of messages are created to asynchronously send the messages.  Our Visual Studio solution will need to connect with an Azure account and be granted the 'Azure Service Bus Data Sender' role.

Once the script above is completed, confirmation that the messages are indeed being sent to the service bus can be seen on the Azure Portal. 

We live in a a world where most of the services we use are already integrated through various methods. This is a method I use, for the integration of two (or more) platforms. 

I am excited to share more development work at Geoson in my next post.