- A CRM Online instance
- Microsoft Azure account
- Microsoft Azure SDK
- Visual Studio 2013/2015
- CRM2016 SDK V8.1 or later ( We will be using the plugin registration tool and sample code from the SDK 8.1 as the SAS featured is added to CRM2016 Update 1)
Setting up a Service Bus Namespace and QueueFor this post we will using the same Service Bus namespace we have created in the last post http://mscrmshop.blogspot.com.au/2016/06/crm-and-azure-service-bus-integration_20.html. We will add a new queue to the existing Service Bus namespace.
- Login to Azure Portal.
- Select the Service Bus namespace. Click the “Queues” tab and select “Create A New Queue”
- Enter the values as shown in the following screenshot and click “Create A New Queue”
- A new queue will be created as shown in the screenshot.
- Double click on the queue name and select “Configure”. Change the general settings as required. I am using the default settings. Create a new policy to mange the access to the queue.
- Click on “DASHBOARD” and select “View Connection String” as shown in the screenshot.
- It will display the "access connection information" as shown in the following screenshot. Copy the connection string. It will be used in the next step.
Setting up the CRM Service EndpointHere are the steps
- Start the plugin registration tool. It is available in the \SDK\Tools location of the SDK. I am using SDK v8.1
- Click on Register>>Register New Service Endpoint
- It will prompt for the connection string. Paste the connection string for the queue here and click “Next”
- The registration tool will display the following page. It will prefill most of the values. I have updated the message format to JSON for this post. Click “Save” to save the service endpoint.
- Select the service endpoint and select "Register New Step", as shown in the screenshot.
- For this blog post I am using create message on account entity. You can chooses the other messages and entities as required. Click “Register New Step” to complete the registration.
Test the IntegrationQueue integration does not require an active listener. So just create a new account from the front end. It should post a message to the queue. You can check status of the integration in the CRM system jobs. view.
Also, you can login to azure. Navigate to the queue and check the queue length. This column displays the number messages received by the queue.
Reading from the queueMicrosoft has provided the Azure sample. For this post, I am using the Azure sample code that comes with the CRM SDK. Here are the steps
- Open the “PersistentQueueListener” project from the location \SDK\SampleCode\CS\Azure\PersistentQueueListener.
- Resolve the missing reference as done in the last blog post (http://mscrmshop.blogspot.com.au/2016/06/crm-and-azure-service-bus-integration_20.html)
- Run the code. Provide the values for service namespace, issuer name and issuer secret.The code will read the message from the queue and display its contents.
Note: The CRM sample code is using the ACS issuer name and issuer secret to generate SAS token. So please provide the ACS values as explained in the last blog.