I’m working with Azure Functions, using
- .NET 6.0
- NServiceBus.AzureFunctions.InProcess.ServiceBus 2.1
I want to publish a message within my Azure Function, so I want to achieve TransportTransactionMode.SendsAtomicWithReceive
as defined here:
However, when I set the AutoComplete to false:
ServiceBusTrigger("ProcessMessageTx", AutoComplete = false)]
my function fails with:
[2021-12-21T20:01:54.853Z] Handling XXXXCommand in XXXCommandHandler
[2021-12-21T20:01:54.966Z] Delayed Retry will reschedule message '792801d2-9913-4d04-8403-ae05014a158d' after a delay of 00:00:10 because of an exception:
[2021-12-21T20:01:54.967Z] Microsoft.Azure.ServiceBus: Local transactions are not supported with other resource managers/DTC.
[2021-12-21T20:01:56.331Z] Executed 'zp_adapt_box' (Failed, Id=627ddf2b-3ae4-460c-9d55-1897942be5fc, Duration=1492ms)
[2021-12-21T20:01:56.333Z] System.Private.CoreLib: Exception while executing function: zp_adapt_box. Microsoft.Azure.ServiceBus: Local transactions are not supported with other resource managers/DTC.
I’m not introducing any transactions as far as I can tell.
My Trigger code:
using System.Threading.Tasks;
using Microsoft.Azure.ServiceBus;
using Microsoft.Azure.ServiceBus.Core;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
using NServiceBus;
namespace gladaptbox;
internal class NServiceBusTrigger
{
private readonly IFunctionEndpoint _functionEndpoint;
public NServiceBusTrigger(IFunctionEndpoint functionEndpoint)
{
_functionEndpoint = functionEndpoint;
}
[FunctionName("XXXXXXXX")]
public async Task Run(
[ServiceBusTrigger("XXXXXXXX", AutoComplete = false)]
Message message,
ILogger logger,
MessageReceiver messageReceiver,
ExecutionContext executionContext)
{
await _functionEndpoint.Process(message, executionContext, messageReceiver, logger);
}
}
My Startup Code:
using System;
using gladaptbox;
using Microsoft.Azure.Functions.Extensions.DependencyInjection;
using NServiceBus;
[assembly: FunctionsStartup(typeof(Startup))]
//[assembly: NServiceBusTriggerFunction(Startup.EndpointName, SendsAtomicWithReceive = true)]
namespace gladaptbox;
public class Startup : FunctionsStartup
{
public const string EndpointName = "zp_adapt_box";
private const string _serviceControlMetricsAddress = "particular.monitoring";
public override void Configure(IFunctionsHostBuilder builder)
{
var services = builder.Services;
builder.UseNServiceBus(
() =>
{
var endpointConfiguration = new ServiceBusTriggeredEndpointConfiguration(EndpointName);
var advancedConfiguration = endpointConfiguration.AdvancedConfiguration;
endpointConfiguration.LogDiagnostics();
// enable audit and error message processing
advancedConfiguration.AuditProcessedMessagesTo("audit");
advancedConfiguration.SendFailedMessagesTo("error");
// enable metrics
var metrics = advancedConfiguration.EnableMetrics();
metrics.SendMetricDataToServiceControl(
serviceControlMetricsAddress: _serviceControlMetricsAddress,
interval: TimeSpan.FromSeconds(10));
return endpointConfiguration;
});
}
}
Any thoughts on why this is happening?
Thanks in adavance - jlo