The TopicFilters sample covers correlation filter too which is setup using an ARM template. The same should be possible in C# and PS as well.
C#
You will have to first create a Microsoft.Azure.ServiceBus.CorrelationFilter
object
var orderPlacedFilter = new CorrelationFilter();
filter.Properties["header_orderType"] = "orderPlaced";
And then add it to your subscription client object by calling Microsoft.Azure.ServiceBus.SubscriptionClient.AddRuleAsync()
subsClient.AddRuleAsync("orderPlacedFilter", orderPlacedFilter);
Similarly, for the other subscription and its filter.
PowerShell
Guess the documentation isn't really great on this one but I believe this should work
$rule = New-AzServiceBusRule -ResourceGroupName prvalav-common -Namespace prvalav-common -Topic test -Subscription test -Name SBRule -SqlExpression "test = 0"
$rule.FilterType = 1
$rule.SqlFilter = $null
$rule.CorrelationFilter.Properties["header_orderType"] = "orderPlaced"
Set-AzServiceBusRule -ResourceGroupName prvalav-common -Namespace prvalav-common -Topic test -Subscription test -Name SBRule -InputObject $rule
If you were wondering about the FilterType = 1
, check the FilterType
enum.
After setting this up, in your function app, you would just use the Service Bus Trigger with the topic/subscription details.