author | ms.service | ms.topic | ms.date | ms.author |
---|---|---|---|---|
ggailey777 |
azure-functions |
include |
01/04/2022 |
glenga |
You can also use the ServiceBusAccountAttribute to specify the Service Bus account to use. The constructor takes the name of an app setting that contains a Service Bus connection string. The attribute can be applied at the parameter, method, or class level. The following example shows class level and method level:
[ServiceBusAccount("ClassLevelServiceBusAppSetting")]
public static class AzureFunctions
{
[ServiceBusAccount("MethodLevelServiceBusAppSetting")]
[FunctionName("ServiceBusQueueTriggerCSharp")]
public static void Run(
[ServiceBusTrigger("myqueue", AccessRights.Manage)]
string myQueueItem, ILogger log)
{
...
}
The Service Bus account to use is determined in the following order:
- The
ServiceBusTrigger
attribute'sConnection
property. - The
ServiceBusAccount
attribute applied to the same parameter as theServiceBusTrigger
attribute. - The
ServiceBusAccount
attribute applied to the function. - The
ServiceBusAccount
attribute applied to the class. - The
AzureWebJobsServiceBus
app setting.