For the complete documentation index, see llms.txt. This section of documentation is indexed by https://docs.particular.net/nservicebus/llms.txt. Here is the markdown version of this page. Markdown versions of documentation pages are available by appending .md to the page URL. Directory URLs use index.md.

Custom Azure Functions triggers

If the trigger function must be customized, you must disable generation of the trigger function by removing the NServiceBusTriggerFunction attribute. A custom trigger function can then be added manually to the project:

class CustomTriggerDefinition(IFunctionEndpoint functionEndpoint)
{
    [Function("MyCustomTrigger")]
    public async Task Run(
        [ServiceBusTrigger("MyFunctionsEndpoint")]
        ServiceBusReceivedMessage message, ServiceBusMessageActions messageActions, FunctionContext context,
        CancellationToken cancellationToken = default)
    {
        await functionEndpoint.Process(message, messageActions, context, cancellationToken);
    }
}

public class Program
{
    public static async Task Main(string[] args)
    {
        var builder = FunctionsApplication.CreateBuilder(args);

        builder.AddNServiceBus("MyFunctionsEndpoint");

        var host = builder.Build();

        await host.RunAsync();
    }
}

The endpoint name in UseNServiceBus must match the queue name in the function, as illustrated above.

Related Articles