Integrate Dynamics 365 CE with Azure Service Bus - no code!

Integrate Dynamics 365 CE with Azure Service Bus - no code!

Do you want to get data from Dynamics 365 or the CDS to an Azure Service Bus without writing any code? Read on my friends.

First, you'll need the following ingredients:

  1. An Azure Subscription
  2. A Dynamics 365 instance
  3. Dynamics 365 CE Plugin Registration Tool
  4. Service Bus Explorer
  5. Pre-heat the oven to 200 degrees C

Now here's an overview of what we're going to do:

  1. Create an Azure Service Bus in the Azure Portal
  2. Create a Queue on the Bus
  3. Create a Shared Access Key (SAS) for writing messages to the Bus
  4. Copy the Connection String
  5. Register a Service EndPoint in Dynamics with the Plugin Registration Tool
  6. Register a Step under the Service EndPoint for the Entity we want to send
  7. Perform a test
  8. Check the results with Service Bus Explorer


Azure Service Bus

1. Create an Azure Service Bus

  • In the Azure Portal, click Create a resource
  • Click Integration, then Service Bus
Azure Portal screenshot - creating a Service Bus
  • Give it a name, select a subscription, resource group and location
Azure Service Bus - Create namespace screenshot

2. Create a Queue

  • After the Service Bus has been created, open it (you might need to go back to All Resources for the subscription).
  • On the left-hand navigation for the Service Bus, click Queues
  • Click + Queue
No alt text provided for this image
  • Provide a name for the queue and leave the other fields as defaults. Remember the queue name, you'll need it later!

3. Create a Shared Access Key (SAS)

  • With the Azure Service Bus pane still open in the Portal, click on the Shared access policies in the left-hand navigation
  • Click Add to create a new one.
No alt text provided for this image
  • Give it a name - something relevant to D365, and make sure it has Send and Listen checked
No alt text provided for this image


4. Copy the Connection String

  • After the SAS has been created above click on it to open the details.
  • Click on the Copy button next to the Primary Connection String. We'll be using this to tell Dynamics 365 where to send messages.
No alt text provided for this image

Dynamics 365 CE

5. Register Service EndPoint

  • Open the Plugin Registration Tool and connect to your D365 instance (assumed knowledge)
  • Click on Register > Register New Service Endpoint
No alt text provided for this image
  • Paste in the Connection String from Step 4
No alt text provided for this image
  • At the next dialog, you'll need to set the Queue Name (from Step 2), and change the Message Format to JSON. I recommend you also put in a Description.
No alt text provided for this image


6. Register a Step

  • After you've done this, right-click on the Service EndPoint and select Register New Step
No alt text provided for this image
  • At the next dialog this is where we define which Entity, and which Message (event). In my example, I am using the Create message of the account entity. Before you click Save, ensure you change the Execution Mode to Asynchronous. I also recommend you put in a better Step Name and Description than the default.
No alt text provided for this image


7. Run a Test

  • For this one we simply need to create an Account. This is an exercise left for the reader.

Check the Service Bus

8. Check results

  • Open Service Bus Explorer
No alt text provided for this image
  • File > Connect Create a new Connection via Connection String - paste in the Connection String from the default SAS that was created when the Azure Service Bus was created. Note this is different to the value we copied in Step 4 (but you'll find it in the same place).
  • Navigate to the Queue we created
  • Click on Messages and click OK on the dialog that pops up.
No alt text provided for this image
  • You should now see some Messages in the queue, and the message text. If you copy / paste the message text into Notepad++ or similar, you can see the sweet sweet JSON.
No alt text provided for this image


Troubleshooting

System Jobs

Did you run a test (Step 7) and nothing appeared in the Service Bus?

If your registration fails for some reason, you can see evidence of this in Settings > System Jobs in Dynamics 365. It will provide you with details of the failure. The first time I tried it, I had pasted in the wrong SAS key and authorization was failing. If the configuration is successful you won't see anything here, it deletes successful jobs.

Related Posts

This post is essentially a combination of the following two Docs:


Clive Saldanha

Senior Solutions Architect at Slalom Build

2 年

Craig Harvey Is there a way to integrate with a session enabled Azure Service Bus Queue to process messages in a particular order?

回复
Mikhail Shlensky

Lead Software?Developer

5 年

?It will be great to add opposite connection procedure from Azure Service Bus To CRM 365.

回复

Nice for fast integration scenario's. I wouldn't recommend this strategy in an environment were you need to reproduce your steps at any time in the future. Please use DevOps tooling and a release-pipeline with an ARM template to deploy the servicebus and consider storing some of the used secrets in a keyvault.

要查看或添加评论,请登录

Craig Harvey的更多文章

社区洞察

其他会员也浏览了