Azure Service Bus Queue Integration with D365 – Part 2

In the previous post of this series, we saw how to create service bus queue and register the service endpoint. In this blog, we’ll continue with the 2nd part of this series.

Part 2: Create account in D365 and the message appears in Service Bus Queue and reading the message from queue

  1. Let’s login to the D365 instance in which we registered the service end point.
  2. Let’s create an account.3
  3. After account is created, let’s browse the queue that we had created in the Azure portal. We’ll see the active message count has been increased to 1.4

Now that after creating account in D365, message has been queued in the queue that we have created, let’s create a sample console application to read the message.

Before creating the console application, let’s have the connection string of service bus namespace that we have created by following below steps:

  1. Browse to the service bus namespace that we had created
  2. Click on Shared Access Policies21
  3. Browse to the key RootManageSharedAccessKey
  4. Copy the primary connection string. We’re going to use this in console application.


Once we have this handy, use the below sample code to read the message from the service bus queue.

public void GetMessage()

const string connectionString = “<Primary Connection String from Step 4 above>”;
const string queueName = “<Name of the service bus queue>”;
var queueClient = QueueClient.CreateFromConnectionString(connectionString, queueName);
BrokeredMessage message = queueClient.Receive();
Dictionary<string, object> keyValuePairs = message.Properties as Dictionary<string, object>;
foreach (var pair in keyValuePairs)
Console.WriteLine(string.Format(“Key: {0}, Value: {1}”, pair.Key, Convert.ToString(pair.Value)));


For executing the above piece of code, we need to install the nuget package “WindowsAzure.ServiceBus” and use the namespace “Microsoft.ServiceBus.Messaging” .


Once we are ready with above, if we execute the console application we’ll get the output in console as shown below:


Once we read the message from queue, it’s removed from the queue.


So, in this blog, we saw how to read the message from queue and how message is queued when we create an account in D365.

Hope it helps !!

3 thoughts on “Azure Service Bus Queue Integration with D365 – Part 2

  1. ok, but the properties are only these? where are all the account fields?
    these info are pretty useless if i cannot see the account properties!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.