Configure Dynamics 365 and Azure Service Bus Integration (using TwoWay relay, Azure Aware Plugin and listener)

Let us pick up from where we left in the previous post and implement two way relaying through which we can get the response back from the listener.

https://nishantrana.me/2017/03/22/configure-dynamics-365-and-azure-service-bus-integration-using-oneway-relay-and-listener/

First let us update the Service Endpoint Registration, change the designation type to TwoWay, it would also ask to enter the SAS Key. Copy it from Azure and paste it.

Update the listener windows application created in the previous post to implement ITwoWayServiceEndpointPlugin

Use the below code to create the custom azure aware plugin.

Get the service endpoint id from the Properties window of the Service End Point registered.

Register the assembly and add the Post Create Synchronous Lead Step to it.

As we are using trace service to log the response, set All for Enable logging to plugin-trace log option from Administration – System Setting – Customization.

Start the listener windows application and to trigger the plugin, create the lead record

We can see the execute method being called from Azure Service bus on create of Lead record.

The message being returned from listener application to the plugin.

The newly created lead record.

The trace message within the plugin –

Plugin Trace log with the response received from the listener –

Hope it helps..

Configure Dynamics 365 and Azure Service Bus Integration (using OneWay relay and listener)

Continuing our previous post

https://nishantrana.me/2017/03/22/configure-dynamics-365-and-azure-service-bus-integration-through-queue-and-queueclient/

Here we’d add a new Shared Access Policy in the Azure Service Bus.

We can copy the connection string

Paste it in Service Endpoint registration dialog box of Plugin Registration tool

Change the designation type to OneWay, use https for the namespace address.

Register a step for creation of lead

Now we go and create a lead record, which triggers our plugin and creates a system job for it.

The system job fails as we do not have any active listener at the end point.

Now let us create a simple windows application which will act as listener.

Basically, we need to implement IServiceEndPointPlugin Interface, create a Service Host, define a new transportclientendpointbehaviour with shared access signature token provider, use WS2007HttpRelayBinding in our service end point.

Now run the listener application, and create a lead record in CRM.

We can see the break point hit in our listener application’ Execute method. Execute method is invoked whenever a message is posted to the service bus by Microsoft Dynamics 365.

System Job also shows the status as succeeded as we had our listener registered to the endpoint and running.

The helpful post

http://www.crmviking.com/2016/10/microsoft-crm-azure-service-bus-part-3.html

https://blogs.msdn.microsoft.com/swetagu/2016/04/12/crm-azure-service-endpoint-and-listener-deep-dive/

http://iunknownme.com/blog/2015/05/27/dynamics-crm-integration-using-azure-service-bus-part-i-using-service-bus-relays/

Hope it helps.

Configure Dynamics 365 and Azure Service Bus Integration (through Queue and QueueClient)

Let us configure Dynamics 365 and Azure Service Bus integration.

Here we would implement a basic scenario, every time a lead is created in CRM we’d pass this execution context information to the queue. The app then reads and shows the information.

As a first step, we need to register a service end point through plugin registration tool.

Here we need to provide the connection string

So, let us create SAS configured Azure service bus namespace and a queue in it.

Go to portal

https://portal.azure.com

Search for Service Bus, provide the required details and click on Create.

Next, we’d create a queue. Inside Service Bus go to Queues and click on plus button create a Queue

Next inside the queue we need to go to Shared Access Policy settings and click on Add button to add a new SAS Key

Next click on connection strings, followed by Add button to add a new SAS Key.

This creates the key. Now copy the connection string.

Paste the connection string in the Plugin Registration tool

It will auto populate all the details. Now click on Save.

This adds a new service end point

Now register a new step – Entity – Lead and Message – Create.

Now to trigger it let us create a lead record in CRM.

A corresponding System Job will have the status.

Back in our queue we can see 1 new message added to it.

To read the message, let us create a simple windows application.

Install the WindowsAzure.ServiceBus package.

The source code for the queue. Here the connection string will be the same which we had specified in the plugin registration tool. The message body is of type RemoteExecutionContext.

The output.

Hope it helps..