Service Bus¶
Handle enterprise messaging with Service Bus queue and topic triggers in PowerShell.
Queue Trigger¶
function.json:
{
"bindings": [
{
"name": "Message",
"type": "serviceBusTrigger",
"direction": "in",
"queueName": "orders",
"connection": "ServiceBusConnection"
}
]
}
run.ps1:
param($Message, $TriggerMetadata)
Write-Information "Received message id $($TriggerMetadata.MessageId)"
Write-Information "Delivery count: $($TriggerMetadata.DeliveryCount)"
Topic and Subscription Trigger¶
{
"name": "Message",
"type": "serviceBusTrigger",
"direction": "in",
"topicName": "events",
"subscriptionName": "audit",
"connection": "ServiceBusConnection"
}
Output Binding¶
{
"name": "OutputMessage",
"type": "serviceBus",
"direction": "out",
"queueName": "notifications",
"connection": "ServiceBusConnection"
}
Dead-Lettering¶
Messages that exceed max delivery count move to the dead-letter subqueue automatically. Monitor and reprocess it separately.
Identity-based connections
Prefer a ServiceBusConnection__fullyQualifiedNamespace app setting with a managed identity over a shared access key connection string. See Managed Identity.