Reputation: 2047
I have an Azure Function that publishes some messages to the service bus, declared like this:
[FunctionName(FunctionNames.PublishMessages)]
public async Task PublishMessages(
[ActivityTrigger] IEnumerable<Foo> messages,
[ServiceBus("TopicName", Connection = "ServiceBusConnectionString")] IAsyncCollector<string> collector,
ILogger log)
{
foreach (var message in messages)
{
await collector.AddAsync(JsonSerializer.Serialize(message));
}
await collector.FlushAsync();
}
The output binding for the service bus takes the name of the topic and the name of the configuration key whose value contains the connection string.
Instead of hard-coding the topic in the method signature I'd like to get it from the function's configuration, in the same way I get the connection string. Is this possible? Any help much appreciated.
Upvotes: 1
Views: 286
Reputation: 16148
You can do that by referencing it using %
. So
[ServiceBus("%TopicNameSetting%", Connection = ...
and create an app setting with the key TopicNameSetting
Upvotes: 1