How to set the Content-Type when sending message to Service Bus from BizTalk

  • Sandro Pereira
  • Feb 10, 2026
  • 3 min read

Understanding the Problem

The Service Bus (SB-Messaging) adapter is used to receive and send messages from Service Bus entities such as Queues, Topics, and Relays. You can use the SB-Messaging adapter to connect your on-premises BizTalk Server to Azure.

📝 One-Minute Brief

Learn how to correctly set the Content-Type when sending messages from BizTalk Server to Azure Service Bus using the SB‑Messaging adapter. Since BizTalk defaults to application/xml—even for non‑XML content like CSV—this guide shows how to set the ContentType property using SB‑Messaging context properties at the orchestration or pipeline level, ensuring the Service Bus message receives the correct MIME type.

The Question

Today, someone asked me how to set the correct Content-Type when sending a message to Service Bus from BizTalk Server, because BizTalk always assigns application/xml by default, even when we send a CSV file.

Service Bus Explorer

My first answer was that you can set that property in the send port under the Properties tab of the Service Bus adapter configuration.

BizTalk Service Bus Explorer Send Adapter

And indeed, yes, this is an option. However, the team told me that the ContentType property didn’t exist!

BizTalk Service Bus Explorer Send Adapter Properties

And they also were correct! I was using BizTalk Server 2020, and they were using BizTalk Server 2016 with different configurations. And yes, indeed, it was always set to application/xml by default.

So the main question was: how to properly set the correct Content-Type?

The Solution

The SB-Messaging adapter provides a set of context properties, specific to SB-Messaging, using the following namespace:

  • Namespace: http://schemas.microsoft.com/BizTalk/2012/Adapter/BrokeredMessage-properties

ContentType is one of them, and is a string value that you can configure.

But you can also find others, such as MessageId, Label, LockToken, ReplyTo, SessionId, TimeToLive, and so on.

See more about Service Bus context properties here: Your Guide to BizTalk Message Context Properties whitepaper.

Although the ContentType property doesn’t appear in the connector configuration, you can still control it. Set the correct value in the send pipeline or inside the orchestration by promoting the ContentType property.

For example, if you use a BizTalk Server orchestration to define your business process and, inside, create a message to be sent to Service Bus, you should define SBMessaging.ContentType in this way:

  • In my proof-of-concept, I will receive the following XML message
<ns0:In xmlns:ns0="http://SettingContentTypeServiceBus.SchemaIn">
  <ContentType>text/plain</ContentType>
</ns0:In>
  • And I have a simple orchestration that receives this message, generates an output message equal to the inbound message, and sets the Content-Type to the value defined in the message body.
msgOut = msgIn;
msgOut(SBMessaging.ContentType) = msgIn.ContentType;
BizTalk Set Content Type

Now, if you test it and check the Service Bus Queue or Topic Subscription, you will see that the contentType property is correctly set to the value we passed.

Service Bus Explorer

If you need to do it inside a custom pipeline component, then you need to set it up like this:

InMsg.Context.Write(
"ContentType",
"http://schemas.microsoft.com/BizTalk/2012/Adapter/BrokeredMessage-properties",
"text/csv"
);

Sample Source Code

You can download the source code from GitHub:

Hope you find this helpful! If you liked the content or found it useful and would like to support me in writing more, consider buying (or helping to buy) a Star Wars Lego set for my son. 

Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.

Leave a Reply

Your email address will not be published. Required fields are marked *

The Ultimate Cloud
Management Platform for Azure

Supercharge your Azure Cost Saving

Learn More
Turbo360 Widget

Back to Top