CRM BizTalk Integration using Azure Service Bus
You may face the same challenges that I experienced when integrating Microsoft Dynamics CRM and BizTalk. The objective is to capture events in real-time and transmit them to an outside system without losing the order of events. There are two web methods exposed by CRM web services, “Retrieve” and “RetrieveMultiple”. The CRM web services provide a way of querying different entities to achieve what we wanted. However, I tried a different approach to solve this integration challenge by using Azure Service Bus Queues. Azure Service Bus Queues provide a robust and flexible implementation of Publish-Subscribe pattern. The picture depicts the scenario that we have implemented.
In this scenario Azure Service Bus (queue) is used as the means of connecting the two pieces of integration, i.e. CRM and BizTalk. The first part of this approach deals with how the Azure Service Bus will communicate with BizTalk. Second part involves how CRM can be easily configured to push messages to the Azure Service Bus Queue.
Part 1: Integration between Azure Service Bus and BizTalk
Steps for creating a new Azure Service Bus Queue:
- Create a new Azure Service Bus with the below command. Download link – Azure Powershell
- Create a queue from the Azure portal
- Create a new BizTalk receive location (BizTalk RL) that will be polling the queue created in previous step for new messages. The BizTalk RL uses the Service Bus adapter. Configure the BizTalk RL by following the steps given below
- Type the Url to the Service Bus Queue in the General Tab
- Type the AccessControl STS Url on the authentication tab. It would be something like, https://<yourservicebusnamehere>-sb.accesscontrol.windows.net/
- Copy and paste the Issuer Name, Issuer Key from the Azure Portal (as shown below) into the authentication tab.
Part 2: Integration between CRM and the Azure Service Bus.
The CRM online instance ships with an “Azure Plugin” that can basically push the different events occurring within CRM to the Azure Service bus. The below series of steps should be followed in order to properly register the Azure plugin in CRM:
Before registering the endpoint you will need the PluginRegistration tool which can be downloaded with the SDK. Download here.
Register the Service Endpoint using Plugin Registration tool:
- Type a suitable name for this service endpoint.
- Type the Azure Service Bus namespace in the Solution Namespace textbox.
- Copy and paste the URL (from the connection string) in the path textbox.
- Click Save & Configure Azure Access Control Service (ACS).
Configure the ACS
- Management Key –Paste the default key of the service bus
- Certificate file – Set to the CRM certificate file
- Issuer Name – set to the issuer name of the CRM application
Register the New Step
- Type the corresponding step/event which will trigger this.
- Type the entity associated with the event.
- Select the newly registered ServiceEndpoint for the Event Handler.
- Click ‘Register New Step’.
These are all the steps needed for configuring the two parts of our integration. Upon creating a new contact record, the CRM step was executed (system jobs) and the message was pushed into the Azure Service Bus Queue. When I enabled the BizTalk receive location, the messages were retrieved from the queue.