Azure Functions integrates with Azure Service Bus via triggers and bindings. Integrating with Service Bus allows you to build functions that react to and send queue or topic messages.
Action
Type
Run a function when a Service Bus queue or topic message is created
This version supports configuration of triggers and bindings through .NET Aspire integration.
Add the extension to your project by installing the NuGet package, version 5.x.
Add the extension to your project by installing the NuGet package, version 4.x.
Functions version 1.x doesn't support the isolated worker process.
Install bundle
The Service Bus binding is part of an extension bundle, which is specified in your host.json project file. You may need to modify this bundle to change the version of the binding, or if bundles aren't already installed. To learn more, see extension bundle.
ICollector<T> or IAsyncCollector<T> where T is one of the single message types ServiceBusSender
1 Messages containing JSON data can be deserialized into known plain-old CLR object (POCO) types.
2 Advanced scenarios include message settlement, sessions, and transactions. These types are available as separate parameters in addition to the normal trigger parameter.
On 30 September 2026, we'll retire the Azure Service Bus SDK libraries WindowsAzure.ServiceBus, Microsoft.Azure.ServiceBus, and com.microsoft.azure.servicebus, which don't conform to Azure SDK guidelines. We'll also end support of the SBMP protocol, so you'll no longer be able to use this protocol after 30 September 2026. Migrate to the latest Azure SDK libraries, which offer critical security updates and improved capabilities, before that date.
Although the older libraries can still be used beyond 30 September 2026, they'll no longer receive official support and updates from Microsoft. For more information, see the support retirement announcement.
This version of the extension supports parameter types according to the table below.
The Service Bus extension supports parameter types according to the table below.
ICollector<T> or IAsyncCollector<T> where T is one of the single message types MessageSender
1 Messages containing JSON data can be deserialized into known plain-old CLR object (POCO) types.
2 Advanced scenarios include message settlement, sessions, and transactions. These types are available as separate parameters in addition to the normal trigger parameter.
On 30 September 2026, we'll retire the Azure Service Bus SDK libraries WindowsAzure.ServiceBus, Microsoft.Azure.ServiceBus, and com.microsoft.azure.servicebus, which don't conform to Azure SDK guidelines. We'll also end support of the SBMP protocol, so you'll no longer be able to use this protocol after 30 September 2026. Migrate to the latest Azure SDK libraries, which offer critical security updates and improved capabilities, before that date.
Although the older libraries can still be used beyond 30 September 2026, they'll no longer receive official support and updates from Microsoft. For more information, see the support retirement announcement.
The isolated worker process supports parameter types according to the tables below.
Service Bus trigger
When you want the function to process a single message, the Service Bus trigger can bind to the following types:
Type
Description
string
The message as a string. Use when the message is simple text.
byte[]
The bytes of the message.
JSON serializable types
When an event contains JSON data, Functions tries to deserialize the JSON data into a plain-old CLR object (POCO) type.
Earlier versions of extensions in the isolated worker process only support binding to string, byte[], and JSON serializable types. Additional options are available to Extension 5.x+.
The clientRetryOptions settings only apply to interactions with the Service Bus service. They don't affect retries of function executions. For more information, see Retries.
Property
Default
Description
mode
Exponential
The approach to use for calculating retry delays. The default exponential mode retries attempts with a delay based on a back-off strategy where each attempt increases the wait duration before retrying. The Fixed mode retries attempts at fixed intervals with each delay having a consistent duration.
tryTimeout
00:01:00
The maximum duration to wait for an operation per attempt.
delay
00:00:00.80
The delay or back-off factor to apply between retry attempts.
maxDelay
00:01:00
The maximum delay to allow between retry attempts
maxRetries
3
The maximum number of retry attempts before considering the associated operation to have failed.
prefetchCount
0
Gets or sets the number of messages that the message receiver can simultaneously request.
transportType
amqpTcp
The protocol and transport that is used for communicating with Service Bus. Available options: amqpTcp, amqpWebSockets
webProxy
n/a
The proxy to use for communicating with Service Bus over web sockets. A proxy cannot be used with the amqpTcp transport.
autoCompleteMessages
true
Determines whether or not to automatically complete messages after successful execution of the function.
maxAutoLockRenewalDuration
00:05:00
The maximum duration within which the message lock will be renewed automatically. This setting only applies for functions that receive a single message at a time.
maxConcurrentCalls
16
The maximum number of concurrent calls to the callback that should be initiated per scaled instance. By default, the Functions runtime processes multiple messages concurrently. This setting is used only when the isSessionsEnabled property or attribute on the trigger is set to false. This setting only applies for functions that receive a single message at a time.
maxConcurrentSessions
8
The maximum number of sessions that can be handled concurrently per scaled instance. This setting is used only when the isSessionsEnabled property or attribute on the trigger is set to true. This setting only applies for functions that receive a single message at a time.
maxMessageBatchSize
1000
The maximum number of messages that will be passed to each function call. This setting only applies for functions that receive a batch of messages.
minMessageBatchSize1
1
The minimum number of messages desired in a batch. The minimum applies only when the function is receiving multiple messages and must be less than maxMessageBatchSize. The minimum size isn't strictly guaranteed. A partial batch is dispatched when a full batch can't be prepared before the maxBatchWaitTime has elapsed.
maxBatchWaitTime1
00:00:30
The maximum interval that the trigger should wait to fill a batch before invoking the function. The wait time is only considered when minMessageBatchSize is larger than 1 and is ignored otherwise. If less than minMessageBatchSize messages were available before the wait time elapses, the function is invoked with a partial batch. The longest allowed wait time is 50% of the entity message lock duration, meaning the maximum allowed is 2 minutes and 30 seconds. Otherwise, you may get lock exceptions.
NOTE: This interval is not a strict guarantee for the exact timing on which the function is invoked. There is a small margin of error due to timer precision.
sessionIdleTimeout
n/a
The maximum amount of time to wait for a message to be received for the currently active session. After this time has elapsed, the session will be closed and the function will attempt to process another session.
enableCrossEntityTransactions
false
Whether or not to enable transactions that span multiple entities on a Service Bus namespace.
1 Using minMessageBatchSize and maxBatchWaitTime requires v5.10.0 of the Microsoft.Azure.WebJobs.Extensions.ServiceBus package, or a later version.
When you set the isSessionsEnabled property or attribute on the trigger to true, the sessionHandlerOptions is honored. When you set the isSessionsEnabled property or attribute on the trigger to false, the messageHandlerOptions is honored.
Property
Default
Description
prefetchCount
0
Gets or sets the number of messages that the message receiver can simultaneously request.
maxAutoRenewDuration
00:05:00
The maximum duration within which the message lock will be renewed automatically.
autoComplete
true
Whether the trigger should automatically call complete after processing, or if the function code manually calls complete.
Setting to false is only supported in C#.
When set to true, the trigger completes the message, session, or batch automatically when the function execution completes successfully, and abandons the message otherwise.
When set to false, you are responsible for calling ServiceBusReceiver methods to complete, abandon, or deadletter the message, session, or batch. When an exception is thrown (and none of the ServiceBusReceiver methods are called), then the lock remains. Once the lock expires, the message is re-queued with the DeliveryCount incremented and the lock is automatically renewed.
In non-C# functions, exceptions in the function results in the runtime calls abandonAsync in the background. If no exception occurs, then completeAsync is called in the background.
maxConcurrentCalls
16
The maximum number of concurrent calls to the callback that the message pump should initiate per scaled instance. By default, the Functions runtime processes multiple messages concurrently.
maxConcurrentSessions
2000
The maximum number of sessions that can be handled concurrently per scaled instance.
maxMessageCount
1000
The maximum number of messages sent to the function when triggered.
შემოუერთდით Meetup სერიას, რათა შექმნათ მასშტაბური AI გადაწყვეტილებები რეალურ სამყაროში გამოყენების შემთხვევებზე დაყრდნობით თანამემამულე დეველოპერებთან და ექსპერტებთან.