You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-signalr/signalr-howto-config-application-firewall.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,7 @@ Client Connection Count Rules restrict concurrent client connections. When a cli
65
65
# [Portal](#tab/Portal)
66
66
To use Application Firewall, navigate to the SignalR **Application Firewall** blade on the Azure portal and click **Add** to add a rule.
67
67
68
-

68
+

Copy file name to clipboardExpand all lines: articles/azure-web-pubsub/howto-config-application-firewall.md
+17-54Lines changed: 17 additions & 54 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,14 @@
1
1
---
2
-
title: SignalR Application Firewall (Preview)
3
-
description: An introduction about why and how to setup Application Firewall for Azure SignalR service
2
+
title: Web PubSub Application Firewall (Preview)
3
+
description: An introduction about why and how to setup Application Firewall for Azure Web PubSub service
4
4
author: biqian
5
-
ms.service: signalr
5
+
ms.service: azure-web-pubsub
6
6
ms.custom: devx-track-azurecli
7
7
ms.topic: how-to
8
8
ms.date: 07/10/2024
9
9
ms.author: biqian
10
10
---
11
-
# Application Firewall for Azure SignalR Service
11
+
# Application Firewall for Azure Web PubSub Service
12
12
13
13
The Application Firewall provides sophisticated control over client connections in a distributed system. Before diving into its functionality and setup, let's clarify what the Application Firewall does not do:
14
14
@@ -21,12 +21,11 @@ The Application Firewall consists of various rule lists. Currently, there is a r
21
21
22
22
This guideline is divided into three parts:
23
23
1. Introduction to different application firewall rules.
24
-
2. Instructions on configuring the rules using the Portal or Bicep on the SignalR service side.
24
+
2. Instructions on configuring the rules using the Portal or Bicep on the Web PubSub service side.
25
25
3. Steps to configure the token on the server side.
26
26
27
27
## Prerequisites
28
-
29
-
* An Azure SignalR Service in [Premium tier](https://azure.microsoft.com/pricing/details/signalr-service/).
28
+
* A Web PubSub resource in [premium tier](https://azure.microsoft.com/pricing/details/web-pubsub/).
30
29
31
30
## Client Connection Count Rules
32
31
Client Connection Count Rules restrict concurrent client connections. When a client attempts to establish a new connection, the rules are checked **sequentially**. If any rule is violated, the connection is rejected with a status code 429.
@@ -45,37 +44,29 @@ Client Connection Count Rules restrict concurrent client connections. When a cli
45
44
**Note:** It's not guaranteed by default that tokens generated by the SDK are different each time. Though each token contaisn a timestamp, this timestamp might be the same if vast tokens are generated within seconds. To avoid identical tokens, insert a random claim into the token claims. Refer to [Configure access token](#configure-access-token).
46
45
47
46
48
-
#### ThrottleByJwtCustomClaimRule
49
-
50
-
More advancedly, connections could be grouped into different groups according to custom claim. Connections with the same claim will be aggregated to do the check. For example, you could add a *ThrottleByJwtCustomClaimRule* to allow 5 concurrent connections for those with custom claim key "freeUser".
51
-
52
-
**Key point**: The rule applies to all claims with a certain claim name. The connection count aggregation is on the same claim (including claim name and claim value). The *ThrottleByUserIdRule* is a special case of this rule, applying to all connections with the userIdentity claim.
53
-
54
-
55
-
56
47
### Best Practice
57
48
#### Avoid using too aggressive maxCount
58
49
59
-
Client connections may close without completing the tcp handshake. SignalR service can't detect those "half-closed" connections immediately. The connection is taken as active until the heartbeart failure. Therefore, aggressive throttling strategies might unexpectedly throttle clients. A smoother approach is to **leave some buffer** for the connection count, for example: double the *maxCount*.
50
+
Client connections may close without completing the tcp handshake. Web PubSub service can't detect those "half-closed" connections immediately. The connection is taken as active until the heartbeart failure. Therefore, aggressive throttling strategies might unexpectedly throttle clients. A smoother approach is to **leave some buffer** for the connection count, for example: double the *maxCount*.
60
51
61
52
62
53
63
54
## Setup Application Firewall
64
55
65
56
# [Portal](#tab/Portal)
66
-
To use Application Firewall, navigate to the SignalR**Application Firewall** blade on the Azure portal and click **Add** to add a rule.
57
+
To use Application Firewall, navigate to the Web PubSub**Application Firewall** blade on the Azure portal and click **Add** to add a rule.
67
58
68
-

59
+

69
60
70
61
# [Bicep](#tab/Bicep)
71
62
72
63
Use Visual Studio Code or your favorite editor to create a file with the following content and name it main.bicep:
73
64
74
65
```bicep
75
-
@description('The name for your SignalR service')
66
+
@description('The name for your Web PubSub service')
// This rule will be skipped if no freeUser claim is set
95
-
type: 'ThrottleByJwtCustomClaimRule'
96
-
maxCount: 10
97
-
claimName: 'freeUser'
98
-
}
99
-
{
100
-
// This rule will be skipped if no paidUser claim is set
101
-
type: 'ThrottleByJwtCustomClaimRule'
102
-
maxCount: 100
103
-
claimName: 'paidUser'
104
-
}
105
84
]
106
85
}
107
86
}
@@ -119,33 +98,17 @@ Deploy the Bicep file using Azure CLI
119
98
120
99
121
100
## Configure access token
122
-
The application firewall rules only take effect when the access token contains the corresponding claim. A rule will be **skipped** if the connection does not have the corresponding claim.
123
101
124
-
Below is an example to add userId or custom claim in the access token in **Default Mode**:
102
+
The application firewall rules only take effect when the access token contains the corresponding claim. A rule will be **skipped** if the connection does not have the corresponding claim. *userId" and *roles* are currently supported claims in the SDK.
103
+
104
+
Below is an example to add userId and insert a unique placeholder in the access token:
0 commit comments