Azure Functions (isolated) for Service Bus Upgrade Version 1 to 2

This version relies on NServiceBus.Transport.AzureServiceBus version 2 which uses the new Azure.Messaging.ServiceBus SDK from Microsoft. See the transport upgrade guide for more details.

Registering NServiceBus

All public constructors of ServiceBusTriggeredEndpointConfiguration have been made internal.

Instead of

functionsHostBuilder.UseNServiceBus(() => new ServiceBusTriggeredEndpointConfiguration(endpointName));

use:

functionsHostBuilder.UseNServiceBus(endpointName);

The endpoint name can be inferred from NServiceBusTriggerFunctionAttribute if present.

[assembly: NServiceBusTriggerFunction("MyEndpoint")]

// ...

functionsHostBuilder.UseNServiceBus(); // Will use the name MyEndpoint
The constructed instance of NServiceBusTriggeredEndpointConfiguration already contains a reference to an IConfiguration instance from the host environment. It is not required to pass one in.

Routing

Instead of

functionsHostBuilder.UseNServiceBus(() =>
{
    var serviceBusTriggeredEndpointConfiguration = new ServiceBusTriggeredEndpointConfiguration(endpointName);
    var routing = serviceBusTriggeredEndpointConfiguration.Transport.Routing();
    routing.RouteToEndpoint(typeof(SomeMessage), "AnotherEndpoint");

    return serviceBusTriggeredEndpointConfiguration;
});

use:

functionsHostBuilder.UseNServiceBus(endpointName, endpointConfiguration =>
{
    endpointConfiguration.Routing.RouteToEndpoint(typeof(SomeMessage), "AnotherEndpoint");
});

Static hosting model has been deprecated

The ServiceBusTriggeredEndpointConfiguration.FromAttributes() static factory method that was used in the preview package has been deprecated. Instead, use the host builder configuration model.


Last modified