I have a service bus trigger function where I want to load the topic name from config
I have seen this post and I have tried the same approach Previous Question
public async Task MyFunctionAsync(
[ServiceBusTrigger("%TopicName%", "data-subscription", Connection = "event-bus-connection")]
string mySbMsg)
{
}
In my localsettings.json file I have
"bindings": [
{
"%TopicName%": "topic"
}
]
"bindings": [ { "%TopicName%": "rockit-notification-topic" } ]
This doesnt work
Microsoft.Azure.WebJobs.Host: Error indexing method 'MyFunction'. Microsoft.Azure.WebJobs.Host: '%TopicName%' does not resolve to a value.
Also, even if this did work, how do I add this to the settings of the function within the portal as this is an item in an array?
You shouldn't add the "bindings" section to you localsettings file. localsettings.json should look something like that:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"event-bus-connection": "test",
"TopicName":"topic",
"SubsriptionName":"data-subscription"
}
}
On Azure Portal you can directly add it to App Service/Function Configuration like properies with name TopicName, SubsriptionName etc.