Skip to content

Commit

Permalink
Add template for basic service bus triggered function
Browse files Browse the repository at this point in the history
  • Loading branch information
PiotrWachulec committed Apr 22, 2024
1 parent 0c82ed3 commit 023e535
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/app/VMStartStop/TagManager/API/ServiceBusQueueTrigger1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Threading.Tasks;
using Azure.Messaging.ServiceBus;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Logging;

namespace MyCo.TagManager
{
public class ServiceBusQueueTrigger1
{
private readonly ILogger<ServiceBusQueueTrigger1> _logger;

public ServiceBusQueueTrigger1(ILogger<ServiceBusQueueTrigger1> logger)
{
_logger = logger;
}

[Function(nameof(ServiceBusQueueTrigger1))]
public async Task Run(
[ServiceBusTrigger("time-trigger-service-bus-queue", Connection = "ServiceBusConnection")]
ServiceBusReceivedMessage message,
ServiceBusMessageActions messageActions)
{
_logger.LogInformation("Message ID: {id}", message.MessageId);
_logger.LogInformation("Message Body: {body}", message.Body);
_logger.LogInformation("Message Content-Type: {contentType}", message.ContentType);

// Complete the message
await messageActions.CompleteMessageAsync(message);
}
}
}

0 comments on commit 023e535

Please sign in to comment.