Integrate Dynamics 365 CE with Azure Service Bus - no code!
Craig Harvey
Business Applications Technical Specialist spreading the awesomeness that is Dynamics 365 and the Power Platform.
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:
- An Azure Subscription
- A Dynamics 365 instance
- Dynamics 365 CE Plugin Registration Tool
- Service Bus Explorer
Pre-heat the oven to 200 degrees C
Now here's an overview of what we're going to do:
- Create an Azure Service Bus in the Azure Portal
- Create a Queue on the Bus
- Create a Shared Access Key (SAS) for writing messages to the Bus
- Copy the Connection String
- Register a Service EndPoint in Dynamics with the Plugin Registration Tool
- Register a Step under the Service EndPoint for the Entity we want to send
- Perform a test
- 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
- Give it a name, select a subscription, resource group and location
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
- 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.
- Give it a name - something relevant to D365, and make sure it has Send and Listen checked
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.
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
- Paste in the Connection String from Step 4
- 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.
6. Register a Step
- After you've done this, right-click on the Service EndPoint and select Register New Step
- 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.
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
- 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.
- 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.
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:
- Walkthrough: Configure Azure (SAS) for integration with Customer Engagement apps
- Walkthrough: Register an Azure-aware plug-in using the Plug-in Registration Tool
- Over time things might change, so worth checking back in with those articles for step-by-step instructions on those different components.
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?
Lead Software?Developer
5 年?It will be great to add opposite connection procedure from Azure Service Bus To CRM 365.
Co-Founder at EVesto
5 年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.