-
Notifications
You must be signed in to change notification settings - Fork 0
/
ServiceBusFunction.cs
33 lines (26 loc) · 1005 Bytes
/
ServiceBusFunction.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System.Text.Json;
using Azure.Messaging.ServiceBus;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Logging;
namespace ServiceBusApp
{
public class ServiceBusFunction
{
private readonly ILogger<ServiceBusFunction> _logger;
public ServiceBusFunction(ILogger<ServiceBusFunction> logger)
{
_logger = logger;
}
[Function(nameof(ServiceBusFunction))]
public async Task Run([ServiceBusTrigger("myqueue1", Connection = "ServiceBusConnection", IsBatched = true)] ServiceBusReceivedMessage[] messages)
{
foreach (ServiceBusReceivedMessage message in messages)
{
_logger.LogInformation("Message ID: {id}", message.MessageId);
_logger.LogInformation("Message Body: {body}", message.Body);
_logger.LogInformation("Message Content-Type: {contentType}", message.ContentType);
}
}
}
}