CRM Integration with Azure Service Bus Queue

Printer-friendly version

Dynamics CRM offers integration with Windows Azure, so I decided to setup a basic example of having updates to the account entity in CRM sent to an Azure Service Bus queue. I am using CRM online, which comes pre-configured to work with Azure. If you’re using CRM on-premise, see the Configure Azure integration with Microsoft Dynamics CRM.

In order to follow along, you’ll need access to a CRM instance and you’ll need an Azure account. For both of these, there are trial options available.

Create the Azure Service Bus Namespace

Normally, you would connect to Azure and use the Classic or New Portal to create a new Service Bus Namespace, which is the container for the Queue. However, this approach no longer works for CRM integration as the default authentication for the service bus namespace is Shared Access Signature (SAS), not Active Directory Access Control Service (ACS). You need to run a Powershell script to create the namespace with ACS. If you do happen to create the namespace via the portal, when you click the Connection Information option, you’ll see information about ACS and this link for more information, Figure 1.

 

Figure 1. Service Bus Namespace Connection Information

Using Powershell, run the following commands using the ISE or from the command-line. Be sure to include the namespace type.

  • Add-AzureAccount
  • New-AzureSBNamespace -Name 'DulferServiceBus' -Location 'West US' -CreateACSNamespace $true –NamespaceType Messaging

The first command allows you to connect to Azure (Figure 2) and the second one creates the Azure Service Bus Namespace with ACS access.

 

Figure 2. Azure Login Prompt

Once the Namespace is created, select it and then view the connection settings by clicking the Connection Information option at the bottom of the screen (Figure 3). Note the ACS section as compared to Figure 1 and the Default Key, which will be needed to create the service endpoint in CRM. At the bottom of the Connection Information screen, there’s an option to open the ACS Management Portal which allows the configuration of service identities, rule groups and a number of other options. However, setting up the service endpoint in CRM sets those options for you, so you don’t have to configure them manually.

 

Figure 3. Namespace Connection Information

Create a Queue

Now that the namespace is created, you can select it and then add a new Queue.

 

Figure 4. Azure Service Bus Listing

 

Figure 5. Azure Service Bus Detail

Select QUEUES, then Create a New Queue. We’ll use the Quick Create option in this case. The Custom Create option works the same, but gives you some additional options for the queue such as size, lock duration, duplicate detection, etc. (see Figure 7).

 

Figure 6. Queue Quick Create

 

Figure 7. Custom Create Queue Options

Once the queue is created (Figure 8), you can view some basic information about it, most notably is the queue length, which indicates the number of messages currently in the queue. 

 

Figure 8. AccountOutbound Queue

Create Service Endpoint in CRM

Now that the queue is in place, launch the CRM Plug-in Registration Tool to create the service endpoint (Figure 9). Click the Create New Connection option to connect to your CRM instance.

  

Figure 9. Plug-In Registration Tool New Connection

Once connected, you’ll see the option to Register.

 

Figure 10. Plug-In Registration Tool Connected to a CRM Instance

Choose Register and then the Register New Services Endpoint option and fill out the form. The Solution Namespace is the one we just created in Azure, the Path is the name of the queue we created and the Contract needs to PersistentQueue as we are using a queue (Figure 11).

 

Figure 11. Registering a new Service Endpoint

Once the registration form is filled out, click the Save & Configure ACS button. You will be prompted with the ACS Configuration form:

  • Management Key: This is the Default Key from the Azure Service Bus Namespace Connection Information.
  • Certificate File: This is the public certificate file that was used to configure Microsoft Dynamics CRM for integration with Microsoft Azure. You can retrieve it from the CRM instance by logging in and going to Settings > Customizations and clicking Developer Resources. Download and save the certificate file using the link provided below Microsoft Azure Service Bus Issuer Certificate.
  • Issuer Name: This name must be the same name that was used to configure Microsoft Dynamics CRM for Microsoft Azure integration. You can obtain the issuer name from the Developer Resources webpage mentioned in the previously.

 

Figure 12. ACS Configuration Completed

Click the Configure ACS button to configure the Azure Fabric ACS to allow posting from CRM. It’s this option that updates the ACS Management Portal options for you. Choose Yes (Figure 13).

Figure 13. Confirm the Configuration of ACS

Click the Close button on the ACS Configuration form and then the Save & Verify Authentication button on the registration form.

 

Click Close and then Cancel from the Service Endpoint Registration form and the new endpoint will be added (Figure 14).

 

Figure 14. Plug-In Registration Tool with new Endpoint

Select the new endpoint, choose Register and Register a New Step. This step will be for changes to the Account entity in CRM, so for the Message use Update and for the Primary Entity use account. Set the Execution Mode to Asynchronous and click the Register New Step button (Figure 15). 

The endpoint uses an out of the box CRM Plug-In to handle the messaging with the service bus, which is quite handy. However, if you need more fine grain control over what’s being sent in the message(s), you can write your own custom Azure-aware plug-in.

 

Figure 15. Register New Step Form

Changes sent to the Azure Queue

Now that a step has been registered to handle updates/changes to an account, whenever you make a change to an account entity in CRM, the changes will be sent to the queue. For example, I just updated the Ticker Symbol field for an account in CRM and those changes were send to the AccountOutbound queue.

 

In CRM, if you go to Settings and then System Jobs, you’ll see the endpoint authentication and the update of the account event.

 

The queue can be accessed by a WebRole, WorkerRole or some other third-party application to retrieve and process those messages as needed. An Azure Service Bus Queue is the simplest delivery option for messages which are first in, first out (FIFO) and will be processed by just one consumer. If you need more of the Publish/Subscribe approach with multiple consumers and rules, then Topics and Subscriptions can be used instead.

For more detail information see Walkthrough: Register an Azure-aware plug-in with the CRM plug-in registration tool or the SDK for One-Way, Two-Way, Rest and other contract type integration.

About the Author:

TopLine Strategies delivers the complete integration and development of sales, marketing and customer service technologies that enable corporate clientele to improve revenue streams and strengthen customer interactions. Our project management and consulting is designed to achieve timely delivery, 100 percent user adoption of the technologies we implement and deliver measurable returns on investments for our clients.

Comments (0)

Related Blogs

TheReact Native Open Source roadmap was announced in Q4 2018 after they decided to invest more in the React Native open source community.

October is not just about pumpkins, fall foliage, and cooler temps anymore. October 2018 also means the exciting introduction of Microsoft Dynamics 365 for Customer Engagement.

Back in 2016, Microsoft introduced its intentions to refresh its CRM and ERP strategy with Dynamics 365. At the heart of its services was the Common Data Model (CDM).