Skip to content

Commit b8053b0

Browse files
committed
Topic filters passwordless
1 parent 64f0b76 commit b8053b0

1 file changed

Lines changed: 45 additions & 2 deletions

File tree

articles/service-bus-messaging/topic-filters.md

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
title: Azure Service Bus topic filters | Microsoft Docs
33
description: This article explains how subscribers can define which messages they want to receive from a topic by specifying filters.
44
ms.topic: conceptual
5-
ms.date: 03/21/2025
6-
ms.custom: sfi-ropc-nochange
5+
ms.date: 03/10/2026
6+
ms.custom: passwordless-dotnet
77
---
88

99
# Topic filters and actions
@@ -35,6 +35,28 @@ A **SqlFilter** holds a SQL-like conditional expression that is evaluated in the
3535

3636
Here's a .NET example for defining a SQL filter:
3737

38+
#### [Passwordless](#tab/passwordless)
39+
40+
```csharp
41+
adminClient = new ServiceBusAdministrationClient(fullyQualifiedNamespace, new DefaultAzureCredential());
42+
43+
// Create a SQL filter with color set to blue and quantity to 10
44+
await adminClient.CreateSubscriptionAsync(
45+
new CreateSubscriptionOptions(topicName, "ColorBlueSize10Orders"),
46+
new CreateRuleOptions("BlueSize10Orders", new SqlRuleFilter("color='blue' AND quantity=10")));
47+
48+
// Create a SQL filter with color set to red
49+
// Action is defined to set the quantity to half if the color is red
50+
await adminClient.CreateRuleAsync(topicName, "ColorRed", new CreateRuleOptions
51+
{
52+
Name = "RedOrdersWithAction",
53+
Filter = new SqlRuleFilter("user.color='red'"),
54+
Action = new SqlRuleAction("SET quantity = quantity / 2;")
55+
}
56+
```
57+
58+
#### [Connection String](#tab/connection-string)
59+
3860
```csharp
3961
adminClient = new ServiceBusAdministrationClient(connectionString);
4062

@@ -52,6 +74,8 @@ await adminClient.CreateRuleAsync(topicName, "ColorRed", new CreateRuleOptions
5274
Action = new SqlRuleAction("SET quantity = quantity / 2;")
5375
}
5476
```
77+
78+
---
5579
### Boolean filters
5680
The **TrueFilter** and **FalseFilter** either cause all arriving messages (**true**) or none of the arriving messages (**false**) to be selected for the subscription. These two filters derive from the SQL filter.
5781

@@ -109,6 +133,23 @@ With SQL filter conditions, you can define an action that can annotate the messa
109133

110134
Here's a .NET example that creates a SQL rule with an action to update the quantity when the color is Red.
111135

136+
#### [Passwordless](#tab/passwordless)
137+
138+
```csharp
139+
adminClient = new ServiceBusAdministrationClient(fullyQualifiedNamespace, new DefaultAzureCredential());
140+
141+
// Create a SQL filter with color set to red
142+
// Action is defined to set the quantity to half if the color is red
143+
await adminClient.CreateRuleAsync(topicName, "ColorRed", new CreateRuleOptions
144+
{
145+
Name = "RedOrdersWithAction",
146+
Filter = new SqlRuleFilter("user.color='red'"),
147+
Action = new SqlRuleAction("SET quantity = quantity / 2;")
148+
}
149+
```
150+
151+
#### [Connection String](#tab/connection-string)
152+
112153
```csharp
113154
adminClient = new ServiceBusAdministrationClient(connectionString);
114155

@@ -122,6 +163,8 @@ await adminClient.CreateRuleAsync(topicName, "ColorRed", new CreateRuleOptions
122163
}
123164
```
124165

166+
---
167+
125168
> [!IMPORTANT]
126169
> When you update system properties through rule actions, it might change the expected behavior. Some properties are only evaluated when a message is received in a queue or a topic. Therefore, when you update these properties in a rule action and then deliver them in a subscription, they're ignored. Although when auto-forwarding to another queue or topic, they're reevaluated.
127170
>

0 commit comments

Comments
 (0)