-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add template for basic service bus triggered function
- Loading branch information
1 parent
0c82ed3
commit 023e535
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/app/VMStartStop/TagManager/API/ServiceBusQueueTrigger1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |