Search code examples
c#azureazure-webjobsazure-webjobssdk

Why Azure webjob unable to execute ProcessQueueMessage when queue message is added in queue?


I wonder why my webjob is not able to execute method ProcessQueueMessage in Functions.cs after find message in queue?

Functions.cs

 public class Functions
    {
        public static void ProcessQueueMessage([QueueTrigger("testqueue")] string logMessage, TextWriter logger)
        {
            logger.WriteLine(logMessage);
        }

I run this webjob it shows following in console.

Found the following functions:
ProcessQueueMessage
Job host started

The problem is the Debugger is not hit when there is any messages added into testqueue.

I already did this last time, and it worked. What did I miss? I have not hosted my webjob on Azure.


Solution

  • I just tried running similar code to yours and it worked fine. The code I ran is a freshly created "Azure WebJob" project in Visual Studio 2015 with Azure SDK 2.7.1.

    However, I made a few observations when trying it out.

    1. It doesn't run using an emulated developer Azure Storage account. Only a storage account hosted in Azure works.
    2. It doesn't give any error messages if the queue doesn't exist or is misspelled. The output is the same, regardless if the queue exists, or not.

    Therefor, verify that the queue you are using ("testqueue") actually exists and is not misspelled. If it doesn't exist, restart the application.

    In my tests, it didn't pick up new queue messages before I restarted the application, after creating the queue.

    For reference, you can find my code here https://github.com/kimpihlstrom/azure/tree/master/Azure.Webjob.SDK.MessageProcessor. Just updated the AzureWebJobsDashboard and AzureWebJobsStorage with some real values.

    The storage account name and key can be found from Azure management portal. Navigate to the storage account and press the "Manage Access Keys" button at the bottom of the screen.