Joe Ruder
Joe Ruder

Reputation: 2194

Show Azure Service Bus Topic Filters

I am working my way through a great tutorial on using Azure PaaS and have come up with a question. Here is the tutorial if it helps anybody else (been pretty useful for me) https://youtu.be/ScJ4VxOmNGs

Is there a way outside of writing a C# program to check what filters are set on a Service Bus Topic Subscription Rule?

I can do this:

var rules = await processPaymentInventoryCheckedClient.GetRulesAsync();

And access them that way, but is there a way using CLI or Powershell? I know that as of the date of this post you cannot do it in the portal.

I tried using Service Bus Explorer, and it shows the rule but not the filter: service bus filter missing

SBE is awesome btw, very helpful if you have not used it: https://github.com/paolosalvatori/ServiceBusExplorer

If I run the above C# code and then drill down into the properties I can verify that the filter is indeed applied:

enter image description here

Thank you --

Joe

Upvotes: 0

Views: 858

Answers (1)

Sean Feldman
Sean Feldman

Reputation: 25994

Regarding ServiceBus Explorer - it's a bug. The tool currently only shows SqlFilters and not CorrelationFilters. I've raised an issue to add support for CorrelationFilters.

To list all filter you can use the following LinqPad script with a free version of the tool:

var connectionString = "<asb-connection-string>";
var topicPath = "<topic-path>";
var subName = "<subscription-name>";
var nsm = NamespaceManager.CreateFromConnectionString(connectionString);

foreach (RuleDescription rule in await nsm.GetRulesAsync(topicPath,subName))
{
  if (rule.Filter is SqlFilter)
  {
    $"Rule: Name = {rule.Name} - 
        SqlExpression = {(rule.Filter as SqlFilter).SqlExpression}".Dump();
  }

  if (rule.Filter is CorrelationFilter)
  {
    $"Rule: Name = {rule.Name} - Correlate = {(rule.Filter as
        CorrelationFilter)}".Dump();
  }
}

Upvotes: 1

Related Questions