I have an Azure Storage Queue that gets messages from an IoT device. The messages are not Base64 encoded, compressed or anything else. They are plain old UTF-8. Here's a sample message:
{"id":"649251ce-5b46-9e3b-ac63-15fe4ffb852c","topic":"/SUBSCRIPTIONS/2BA02699-F96D-4474-BC02-888E2CF968F8/RESOURCEGROUPS/MYRESOURCEGROUP/PROVIDERS/MICROSOFT.DEVICES/IOTHUBS/DVV1234","subject":"devices/DT12345","eventType":"Microsoft.Devices.DeviceTelemetry","eventTime":"2024-12-12T14:20:13.311Z","data":{"properties":{"alarm":"","history":null,"current":null,"devicemsg":null,"mqtt-dup":null},"systemProperties":{"iothub-connection-device-id":"DV12345","iothub-connection-auth-method":"{\"scope\":\"device\",\"type\":\"sas\",\"issuer\":\"iothub\"}","iothub-connection-auth-generation-id":"637432295369411031","iothub-enqueuedtime":"2024-12-12T14:20:13.311Z","iothub-message-source":"Telemetry"},"body":"IHsiRFQiOnsiVCI6ICIyMDI0LTEyLTEyIDE0OjIwOjE1In0gLCAiVW5pdCI6eyJJRCI6IjEwMTIzNDUiLCJOYW1lIjoiRFQxMjM0NSJ9LCAiQVMiOltdfQ=="},"dataVersion":"","metadataVersion":"1"}
My Azure queue triggered function is not reading these messages. Instead, it is just logging this message to the console for every message that drops in the queue: [2024-12-12T14:31:09.342Z] Message has reached MaxDequeueCount of 5. Moving message to queue 'mqtt-inbound-poison'.
I have stripped the code down to the most basic queue trigger function app: Program.cs:
using Microsoft.Azure.Functions.Worker.Builder; using Microsoft.Extensions.Hosting; var builder = FunctionsApplication.CreateBuilder(args); builder.ConfigureFunctionsWebApplication(); // Application Insights isn't enabled by default. See https://aka.ms/AAt8mw4. // builder.Services // .AddApplicationInsightsTelemetryWorkerService() // .ConfigureFunctionsApplicationInsights(); builder.Build().Run(); Function1.cs:
using System; using Azure.Storage.Queues.Models; using Microsoft.Azure.Functions.Worker; using Microsoft.Extensions.Logging; namespace inboundtest { public class Function1 { private readonly ILogger<Function1> _logger; public Function1(ILogger<Function1> logger) { _logger = logger; } [Function(nameof(Function1))] public void Run([QueueTrigger("mqtt-inbound", Connection = "MyStorage")] QueueMessage message) try { _logger.LogInformation($"C# Queue trigger function processed: {message.MessageText}"); } catch { _logger.LogError("An error occurred processing the message."); } } } } But the message about the MaxDequeueCount is all I get. I am 100% certain my queue name, mqtt-inbound, is correct. I am also certain the connection string is correct as I selected the storage account in Visual Studio when creating the project. I just built this minimal test code this morning and I am using the latest and greatest NuGet packages. Since neither my try nor catch message is being logged to the console, I suspect something is occurring before my function has even run, but what? What are my next steps in troubleshooting this?
