I'm trying to setup an Azure Function that is triggered by a new message in an Azure Storage Queue. I have the code setup to send messages to the Queue as follows:
QueueClient queue = new(connectionString, queueName);
await queue.SendMessageAsync(message);
This part works fine. When I pass in the connectionString, queueName, and message, I can see the message sitting in the Queue on the portal.
This is the part I'm having trouble understanding. I setup an Azure Function using the Azure Storage Queue template, and the queue it's referencing is the same as queueName. However, when a message gets added to the queue, the Azure Function doesn't log anything. From what I understood, the Azure Function should be triggered by a message being added to the queue it's pointed it, and it should log the message. I tried both the .NET Core 3.1 In Process and .NET 5 isolated process. I'm not sure what I'm missing here, or if I'm misunderstanding something. This is the code for the Azure Function (.NET 5).
[Function("QueueTrigger1")]
public static void Run([QueueTrigger("myqueue-items", Connection = "something_STORAGE")] string myQueueItem, FunctionContext context)
{
var logger = context.GetLogger("QueueTrigger1");
logger.LogInformation($"C# Queue trigger function processed: {myQueueItem}");
}
This is the program.cs
public static void Main()
{
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.Build();
host.Run();
}
This is the host.json
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
}
}