Why is my ServiceBusTrigger not getting triggered?

1.8k Views Asked by At

I have a Azure Function App that process some messages from Azure Service Bus Topic. I have some messages passed to the ASB and there are messages coming under my topic's subscription. However when I run my app locally which points to that specific subscription, it still doesn't get triggered. I do have configured my app properly with all the connection string. How would you suggest to diagnose this issue?

Just for context: I have it configured in my local settings with needed parameters.

1

There are 1 best solutions below

4
On
  • Check your connection property of ServiceBusTrigger attribute which should refer to ServiceBusConnectionString.
  • Now, you need to provide the same name in local.settings.json for local and app settings for azure.
  • Below is the sample code for ServiceBusTrigger with Azure Functions.

 [FunctionName("ServiceBusQueueTriggerCSharp")]                    
    public static void Run(
        [ServiceBusTrigger("myqueue", Connection = "ServiceBusConnection")] 
        string myQueueItem,
        Int32 deliveryCount,
        DateTime enqueuedTimeUtc,
        string messageId,
        ILogger log)
    {
        log.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
        log.LogInformation($"EnqueuedTimeUtc={enqueuedTimeUtc}");
        log.LogInformation($"DeliveryCount={deliveryCount}");
        log.LogInformation($"MessageId={messageId}");
    }

  • Check this Microsoft Document for complete information regards to creation of Azure Function with Azure ServiceBus trigger.