Код: Выделить всё
{"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"}Код: Выделить всё
[2024-12-12T14:31:09.342Z] Message has reached MaxDequeueCount of 5. Moving message to queue 'mqtt-inbound-poison'.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();
Код: Выделить всё
using System;
using Azure.Storage.Queues.Models;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Logging;
namespace inboundtest
{
public class Function1
{
private readonly ILogger _logger;
public Function1(ILogger 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.");
}
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/792 ... e-messages
Мобильная версия