Skip to content

Instantly share code, notes, and snippets.

@finesse-fingers
Last active April 26, 2020 05:33
Show Gist options
  • Save finesse-fingers/c49c35fdad7f342bfd49bebb4cbd8623 to your computer and use it in GitHub Desktop.
Save finesse-fingers/c49c35fdad7f342bfd49bebb4cbd8623 to your computer and use it in GitHub Desktop.
Azure function servicebus queue trigger with MessageReceiver binding
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingExcludedTypes": "Request",
"samplingSettings": {
"isEnabled": true
}
}
},
"extensions": {
"serviceBus": {
"messageHandlerOptions": {
"maxConcurrentCalls": 8,
"maxAutoRenewDuration": "00:55:00",
"autoComplete": false
}
}
}
}
[FunctionName("SbusQueueTriggerFunction")]
public async Task RunAsync(
[ServiceBusTrigger("%QueueName%", Connection = "SbusConnectionString")]
Message message,
MessageReceiver messageReceiver,
ILogger log)
{
// ...
// dead-letter the msg
await messageReceiver.DeadLetterAsync(message.SystemProperties.LockToken, "reason: ...");
// manually complete the message
await messageReceiver.CompleteAsync(message.SystemProperties.LockToken);
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment