Azure Service Bus .NET Standard Transport

Component: Azure Service Bus Transport for .NET Standard
NuGet Package NServiceBus.Transport.AzureServiceBus (1-pre)
Target NServiceBus Version: 7.x
This page targets a pre-release version and is subject to change prior to the final release.

Prerequisites

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

Code walk-through

This sample shows a simple two-endpoint scenario.

  • 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.SendFailedMessagesTo("error");
endpointConfiguration.EnableInstallers();

var transport = endpointConfiguration.UseTransport<AzureServiceBusTransport>();

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.");
}
transport.ConnectionString(connectionString);

Viewing message 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


Last modified