Dynamics CRM and Azure Service Bus Queues Messaging over the cloud


Dynamics CRM and Azure service bus integration Part 4

Install the CRM Endpoint Service

The fourth and final part of the CRM Connector blog details how to install and configure the CRM Endpoint service to listen for messages sent via the Azure service bus queue.  The endpoint service is a compact windows service that registers its interest on messages placed on the Azure service bus queue.  Whenever a message arrives we take the message and places it on a local queue (by default MSMQ) for further processing.

The destination queue is defined in the plugin configuration <endpoint> element.  The endpoint service reads this entry from the queue and places the resulting output from the FetchXML onto this queue for processing by your backend.


I wont go into to much detail on the installation of the service as its just a standard windows installation.  However there are a couple of configuration options in the app.config that bear discussion.

We need to set the OwinService.ASBEndpoint to the confguration created in part1

 <add key="OwinService.ASBEndpoint" value="Endpoint=sb://fortesevicebus.servicebus.windows.net/;SharedAccessKeyName=ReadWriteToQueue;SharedAccessKey=V8j7VPqA.../Hc=;EntityPath=crm365queue" />

After running the service and pushing a messages onto the queue, we see something xml like

<xml version="1.0">
<GenericMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.net/CRMWebToQueue.Types">
 <Message>{"__contract":"update_customeraddress_bad5c2bf-6dd3-4f7e-aef7-474658982395","operation":"Update","columns":["city","postalcode","line1","line2","line3","county","fort_pin","fort_name"],"entity":"customeraddress","id":"bad5c2bf-6dd3-4f7e-aef7-474658982395","county":"UNITED KINDGOM","createdby":"efde08b0-26e3-4ac3-818b-84fb808b12db","createdby_formatted":"Robert Hawkins","line3":"EAST MIDLANDS","postalcode":"PE20 3EA","fort_registrant.fort_name":"2017A0001 / 2004","fort_registrant.fort_pin":"2017A0001","line1":"8 WITNEY WAY","line2":"KIRTON"}</message>;

if we extract the message node its just the JSON representation of the FetchXML result

 "county":"UNITED KINDGOM",
 "line3":"EAST MIDLANDS",
 "postalcode":"PE20 3EA",
 "fort_registrant.fort_name":"2017A0001 / 2004",
 "line1":"8 WITNEY WAY",

The columns element represents the output columns of the FetchXML, this is necessary because by default FetchXML does not output empty nodes.
The problem with this is if we request data thats null or empty in CRM we do not get an empty results node. In the example above we requested
column [City] but there is no corresponding { “city” : ??? } in the result as this entity has a null or empty [City].

4 thoughts on “Dynamics CRM and Azure Service Bus Queues Messaging over the cloud

Leave a Reply

Your email address will not be published. Required fields are marked *