azure-functionsmessage-queueazure-queues

How to Invoke queue trigger function?


I have created a simple trigger function from a template, this is working perfectly fine if I debug from Visual Studio, which is once I add message manually to my queue, I can see that message in debug output in my Visual Studio.

So, I plan to publish it to my portal, and now, if I add a message to queue, I do not see any output in the kudu terminal and I do not see any message getting dequeued.

How can the queue trigger function be invoked?

This is my simple code:

[Function(nameof(Function1))]
public string Run([QueueTrigger("sample", Connection = "ConnString")] QueueMessage message)
{
    _logger.LogInformation($"C# Queue trigger function processed: {message.MessageText}");
    return message.MessageText;
}

And this is the output from app service editor terminal

app service editor terminal

Sorry if its sound lame, am new to Azure :)

Thanks a ton in advance!


Solution

  • You can directly see the logs in the Invocations of the Function in the Azure Function App.

    After deployment, make sure to add the queue connection in the Function app > Environment variables > App settings as shown below,

    ConnString": "<storageConneString>
    

    enter image description here

    I have sent a message in the Azure storage queue as shown below,

    enter image description here

    Azure Function App Invocations :

    After some time, I got the logs in the Function under Invocations as shown below.

    enter image description here

    Function1.cs :

    using Azure.Storage.Queues.Models;
    using Microsoft.Azure.Functions.Worker;
    using Microsoft.Extensions.Logging;
     
    namespace FunctionApp8
    {
        public class Function1
        {
            private readonly ILogger<Function1> _logger;
     
            public Function1(ILogger<Function1> logger)
            {
                _logger = logger;
            }
     
            [Function(nameof(Function1))]
            public void Run([QueueTrigger("sample", Connection = "ConnString")] QueueMessage message)
            {
                _logger.LogInformation($"C# Queue trigger function processed: {message.MessageText}");
            }
        }
    }
    

    local.settings.json :

    {
        "IsEncrypted": false,
      "Values": {
        "AzureWebJobsStorage": "UseDevelopmentStorage=true",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
        "ConnString": "<storageConneString>"
      }
    }