Azure functions do not work with Azure Service Bus topics

Antonio Andrés Avila Moreno 0 Reputation points

I create an Azure Function of type Service Bus with theme, from Visual Studio 2022 Community Edition using C#, I configure the connection with a full permissions endpoint.

When trying to do debugging, it doesn't do anything and in the output window, after loading the symbols, sometimes it just puts an error, but other times it doesn't put anything.

The service bus contains at least 5 messages with 2 subscriptions, one with the session enabled and the other with the session disabled.

The error that sometimes gets displayed in the output window is:

Exception thrown: 'Azure.RequestFailedException' in System.Private.CoreLib.dll

I have used both the libraries with the version that the project is created (Microsoft.NET.Sdk.Functions 4.1.1 and Microsoft.Azure.WebJobs.Extensions.ServiceBus 4.3.0), even using the latest versions of these components (Microsoft. NET.Sdk.Functions 4.2.0 and Microsoft.Azure.WebJobs.Extensions.ServiceBus 5.9.0)

This happens to me both with subscriptions with the session option enabled or disabled.



Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
468 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
3,674 questions
{count} votes

1 answer

Sort by: Most helpful
  1. MuthuKumaranMurugaachari-MSFT 18,176 Reputation points

    Antonio Andrés Avila Moreno Thanks for posting your question in Microsoft Q&A. Based on your description, you face this issue with .NET 6, however .NET 3.1 works fine. Can you confirm if you have Connection string with secret or using Identify based connections? (Since you have tested in Postman, I guess it is likely secret).

    Here is my local test which works fine without any errors and you can try with the same.


    User's image


    User's image


    public class Function1
            private readonly ILogger<Function1> _logger;
            public Function1(ILogger<Function1> log)
                _logger = log;
            public void Run([ServiceBusTrigger("mtopic", "msubscription", Connection = "MSBCONNECTION")]string mySbMsg)
                _logger.LogInformation($"C# ServiceBus topic trigger function processed message: {mySbMsg}");

    mtopic - my topic name

    msubscription - my subscription in mtopic

    MSBCONNECTION - connection string with secret for SB namespace (not topic or queue) as suggested in doc:

    If you still face the issue, share local.settings.json (hiding connection string), full .csproj reference, that will help in reproducing the issue. I hope this helps and let me know if you still face the issues.