AI agents: use the documentation index at llms.txt to locate machine-readable pages. This section is indexed by https://docs.particular.net/samples/llms.txt. The markdown version of this page is served as plain text. An MCP server at /mcp serves the same content via the search_docs and read_doc tools; it is read-only and needs no credentials. Markdown versions of documentation pages are available by appending .md to the page URL. Directory URLs use index.md. They are served as text/plain because some retrieval backends reject text/markdown.

Azure Service Bus Send/Reply Sample

NuGet Package:
NServiceBus.Transport.AzureServiceBus 6.x
Target Version:
NServiceBus 10.x

Prerequisites

An environment variable named AzureServiceBus_ConnectionString with the connection string for the Azure Service Bus namespace.

Code walk-through

This sample shows a basic two-endpoint scenario exchanging messages with each other so that:

  • Endpoint1 sends a Message1 message to Endpoint2.
  • Endpoint2 replies to Endpoint1 with a Message2 instance.

Transport configuration

var endpointConfiguration = new EndpointConfiguration("Samples.ASBS.SendReply.Endpoint1");
endpointConfiguration.EnableInstallers();

var connectionString = Environment.GetEnvironmentVariable("AzureServiceBus_ConnectionString");
if (string.IsNullOrWhiteSpace(connectionString))
{
    throw new Exception("Could not read the 'AzureServiceBus_ConnectionString' environment variable. Check the sample prerequisites.");
}

var transport = new AzureServiceBusTransport(connectionString, TopicTopology.Default);
endpointConfiguration.UseTransport(transport);
endpointConfiguration.UseSerialization<SystemJsonSerializer>();

Viewing messages in-flight

The following queues for the two endpoints can be seen in the Azure Portal or a third-party tool:

  • samples.asbs.sendreply.endpoint1
  • samples.asbs.sendreply.endpoint2
  • error

Related Articles