Try for free Book a demo

Azure Service Bus Logging with BAM – Walk-through

Distributed Tracing

7 Mins Read | Last modified on July 25th, 2024

Azure Service Bus Logging

In the previous article, we talked about how you could use BAM to do advanced management of dead lettered messages on the Azure Service Bus using a scenario like below.

Azure Service Bus Logging

This article will show how you can set up this kind of example. Let’s assume your Order Processing functions are already in place, and your starting point is that sometimes you will get dead-lettered messages, and we need to implement the Send message to the BAM logic app and configure Turbo360.

Step 1 – Setting up BAM

To keep this article concise, I assume you have already set up the distributed tracing feature(BAM) in Turbo360 and are ready to start building your business processes. If you are new to BAM and have not set it up yet, there is a walk-through in the documentation article.

Step 2 – Go to BAM

We need to access the Turbo360 portal and go to the BAM area.

Go to BAM

Step 3 – Global Properties

Now we need to set up some Global Properties. Global Properties are properties that you want to search on, and they are properties that will likely be common to your business. To edit the Global Properties, you need to do actions and access the screen below.

Global Properties

If you have any existing properties set up, they will be shown here, and you can add a new one.

Manage Global Properties

Give your property a name, choose the data type, and click Save.

Create global property

When setting up the global properties, you want to think about properties in your message or the service bus message properties you wish to search on. The ones I used are:

  • Order ID from the body of my message
  • Customer ID from the body of my message
  • The Error which will come from the service bus dead letter reason
  • Message-ID, which will come from the service bus message

Once I have set up the properties I need, I will now set up my business process. If required, I can modify properties later and add new ones.

Step 4 – BAM Business Process

Next, we need to set up our Business Process. Back on the BAM home page, you can click to add a new business process.

BAM Business Process

Give your BAM Business Process a name and description and save it.

Create Business Process

You will now see your business processed, and you can click on it to open it up. 

Step 5 – BAM Transaction Setup

A business process is a container for a group of transactions. In the case of this scenario, we only need one transaction, and it will be a simple one. Go to the top right of the Business Process screen and click add transaction to create the transaction.

BAM Transaction Setup

Give your transaction a name. It is probably reasonable to pick a name that indicates it relates to the specific queue you are managing the dead letter messages for. Then click Save.

Create Business Transaction

The transaction designer will open, and you can start adding shapes for your transaction if you click the edit button at the top.

Edit

If you now click the Add Stage button to add a shape to the designer, you can then give it a name, drag it to the right place, and connect up the lines to represent any flow.

Add Stage

If you now hover over the three tiny dots on the shape you added, it will show some options to edit that shape. The middle one allows you to indicate which properties will be supplied to that Action.

Configure

You can add the Logic App properties that push dead letter messages to BAM. Properties can come from the message body or the message context sent to BAM. Below you will see some of the properties I have added.

Add property

In my example, the Customer-ID property is queried from the message body using a JSON query $.CustomerNo. The Error will come from a message context property the Logic App will send, and it will include the dead letter reason from Service Bus to make it easier for the BAM users to see what the problem was.

You can also add constants properties if you want to provide additional information to the BAM user. I sometimes use this to communicate the source and destination applications involved in a BAM process, as it often helps people understand where the transaction relates to.

Note – In the image above, you can see properties with a globe on the left are global searchable properties, and you can also specify local properties, but these are not searchable.

Step 6 – BAM Reprocessing Stage

I can also specify a reprocessing stage for the BAM shape on the transaction. Back on the transaction, I will hover over the shape, and the wrench icon is the one to click to configure reprocessing.

BAM Reprocessing Stage

You can now supply some information about how you want to reprocess the messages. Below, you can see that I have configured a Service Bus queue to be the destination I will push a message to for reprocessing.

Configure reprocessing

Our transaction can be saved, and we are now ready to set up our Logic App to push dead letter messages to BAM.

Step 7 – Logic App

I assume that you have a blank Logic App and have set up the connector for BAM as described in this article.

In my new Logic App, I will use the Service Bus trigger and change the queue type to point to the dead letter queue.

Logic App

I will then use the compose shape to decode the service bus message body.

Compose

I then add the BAM Start Transaction action to send the message to BAM. I need to supply the following info, which must match what I have configured in BAM:

  • Turbo360-BusinessProcess = The Business Process Name
  • Turbo360-Transaction = The Transaction Name you configured within the business process
  • Turbo360-Stage – The stage shape you drew in the BAM transaction designer
  • Azure Service Bus Logging

I am setting the stage status to fail, so I know the transaction is an error and will show up in the Action Required list.

For the MessageBody property, I am setting the message body from Service Bus. Any BAM properties linked to the message body will match against this using JSON query of XPath or regex.

For the MessageHeader, I am sending the properties from the service bus message. This will give me all of the properties available to link to my BAM properties.

Below is an example of the properties I get, and you can see this automatically gives me the Service Bus Dead letter Reason.

Azure service bus log all messages

At this point, I can save and enable my Logic App, and it will begin processing the dead letter queue and pushing any messages to BAM.

What’s Next

If you remember in the original overview article where I talked about the approach, I showed some of the features in Turbo360 you now have available to enhance your dead letter processing experience with the following features:

  • Search by body/properties
  • Action Required
  • Favourite
  • Reprocess / Repair and Resubmit
  • Dashboards

Hopefully, this shows it’s pretty easy to set up BAM to do this. Suppose you’re already using BAM for tracking your complex processes. In that case, this is an easy way you can also use it to have a great support experience for your business users, application owners and IT, support operators.

Try BAM

If you want to explore how BAM can help you implement interfaces that integrate with SAP or other systems using the Microsoft Integration Services, go to the Azure Distributed Tracing Tool for more info and a trial.

This article was originally published on Jan 24, 2022. It was most recently updated on Jul 25, 2024.

Azure Service Bus - Request Demo CTA

Related Articles