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
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.
Hope it helps..
14 thoughts on “Configure Dynamics 365 and Azure Service Bus Integration (through Queue and QueueClient)”
Greate post, thanks for sharing!
LikeLiked by 1 person
Great work mate. I am a fan of your blogs from early CRM years 🙂
NET CRM 2016 Update 1 Dynamics 365 Microsoft Dynamics […]
Thanks for sharing this information. Is it possible to get data into CRM from the Servicebus?
Go for two way relay. https://nishantrana.me/2017/03/22/configure-dynamics-365-and-azure-service-bus-integration-using-twoway-relay-azure-aware-plugin-and-listener/
A little note: you mention installing the WindowsAzure.ServiceBus package, but there is one more package you need for your example code to work and that is the Microsoft.CrmSdk.CoreAssemblies package.
Hope this can help someone running into the same issue I did
LikeLiked by 1 person
Its very good post to pass data from CRM to Azure service Bus. Could you please tel me how to pass data from azure service bus to CRM. Thanks in advance.
I am trying to debug plugin code and getting below error
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=184.108.40.206, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Failed to retrieve the service bus service.
at AzureAwareSandboxPlugins.ContactAzurePlugin.Execute(IServiceProvider serviceProvider)
at PluginProfiler.Library.PluginAppDomainProxy.ExecuteCore(Stopwatch watch, ProfilerExecutionReport report, Object instance, Object executionParameter)
at PluginProfiler.Library.AppDomainProxy.Execute(ProfilerExecutionConfiguration configuration, ProfilerExecutionReport report)
Failed to retrieve the service bus service.
I checked when I dont debug plugin is working fine.
Let me know what I can do in this situation.