# Azure Service Bus : Using Power Automate to Send Messages from Dataverse

With limitations in Dataverse for long-running code, some of the logic could be outsourced to Azure.

Let's say the accounts created in Dataverse also needs to be sent to 3rd party web applications, it is possible to make direct API calls and create these records in the web applications or one of the other ways is to send the message to the service bus and from there, either a web job or an azure function could pick the message and create those records in other applications, this prevents the plugin from doing all the heavy lifting work. Service bus helps in decoupling applications from each other.

There are numerous ways to send messages from Dataverse to service bus queues.  
It could be a c# code that sends the message or service endpoint registrations etc.  
[Azure aware plugin](https://learn.microsoft.com/en-us/power-apps/developer/data-platform/write-custom-azure-aware-plugin)  
[Register service endpoint](https://arunpotti.com/2023/01/06/how-to-register-service-endpoint-in-the-dataverse-plugin-registration-tool/)  
In this article let's see how we could use power automate cloud flow to send the message to the Azure service bus queue when an account is created in Dataverse

<details data-node-type="hn-details-summary"><summary>Setting up the Azure account</summary><div data-type="detailsContent"><a target="_blank" rel="noopener noreferrer nofollow" href="https://azure.microsoft.com/en-us/free" style="pointer-events: none">Try Azure for free</a></div></details>

To set up your Azure service bus in the Azure portal go to portal.azure.com  
search for azure service bus, this would need us to create the service bus namespace first.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691653433750/aaacd7b6-cb4c-455d-a36c-34a0f01b94b0.png align="center")

After creating the service bus namespace, we can create the queue

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691653512391/768671de-d9fa-4dc5-a09e-01e4c4275147.png align="center")

sample queue

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691653620009/7c8065ff-5d22-4056-9b76-6f2ee8de0290.png align="center")

Now, this completes the service bus queue setup.

### Sending messages to service bus queue from Power Automate cloud flow

In the power automate cloud flow select the dataverse trigger 'When a row is added, modified or deleted'

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691653880919/a0f36a73-3614-461c-849e-04eb34b4a2f5.png align="center")

Create a compose action to add the fields that we would want to send to the service bus

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691653905586/60acd3e7-6082-4a7c-b8ff-1da9e1a29a90.png align="center")

The next step is to add the service bus action

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691653957631/fe2b2742-8a03-4135-abcf-639fef4c0a79.png align="center")

Look for the access key, which can be fetched from the azure portal under the service bus namespace, click on the Share access policies and RootManageSharedAccesskey and copy the primary connection string.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691654161922/f1ce9559-4d35-4c68-b6f0-721bbe02e3ab.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691654108862/fd6aca9e-ce30-4a9c-9229-aa25ff3306d0.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691654194169/329fc304-7ed7-4766-a57d-16fef320fd1c.png align="center")

This completes the flow creation process.

To test this, create an account in the dataverse and see the flow execution, if its successful, go to the azure portal and in the queue select service bus explorer and look for the peek message option, you will be able to see the message

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691654404254/4a4d7e9d-0028-4fe1-9290-5c57368fe2f8.png align="center")

This is a simple example of how messages from Dataverse could be sent to the Azure service bus. This message can then be consumed by other applications  
[Update records in Dataverse using azure functions](https://beyondd365.dev/azure-function-read-messages-from-queue-and-update-record-in-dataverse)
