Reputation: 11599
I created an Azure Function and selected Azure Service Bus Topic as the trigger in Visual Studio 2019. I also created a Service Bus Topic in my Azure account and have the Primary Connection String and Primary Key.
My questions are:
[FunctionName("Function1")]
public static void Run([ServiceBusTrigger("mytopic", "mysubscription", Connection = "ConnectionString")]string mySbMsg, ILogger log)
{
log.LogInformation($"C# ServiceBus topic trigger function processed message: {mySbMsg}");
}
Upvotes: 0
Views: 8506
Reputation: 1556
There is in ServiceBusTrigger 2 overloads:
public ServiceBusTriggerAttribute(string queueName);
public ServiceBusTriggerAttribute(string topicName, string subscriptionName);
You can choice.
Upvotes: 0
Reputation: 625
You have to change the tree attributes, and add them to the local.settings.json: You will have your Trigger like this:
[ServiceBusTrigger(
topicName: "%MyServiceBus.Topic%",
subscriptionName: "%MyServiceBus.Subscription%",
Connection = "MyServiceBus.Connection")]
And your local.settings.json like this:
{
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"PriorityBoardingFare.Topic": "TestEvent",
"PriorityBoardingFare.Subscription": "Appl1cation1",
"PriorityBoardingFare.Connection": "Endpoint=sb://xxxxxxxxx.windows.net/;SharedAccessKeyName=xxxxxxd;SharedAccessKey=adasdasdasdasdasdasd"
},
"Host": {
"LocalHttpPort": 21094
}
}
To send or manage the service bus you have now available two options:
Upvotes: 4