Skip to content

Commit 8744de2

Browse files
authored
Merge pull request #285694 from MicrosoftDocs/main
Publish to Live Wednesday 4AM PST 8/28
2 parents 155f2c9 + 15a7940 commit 8744de2

16 files changed

+763
-107
lines changed

articles/azure-monitor/toc.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,13 +1000,6 @@ items:
10001000
href: logs/delete-workspace.md
10011001
- name: Replicate workspace across regions
10021002
href: logs/workspace-replication.md
1003-
- name: Manage access
1004-
displayName: Manage access to a Log Analytics workspace
1005-
href: logs/manage-access.md
1006-
- name: Change pricing tier
1007-
href: logs/change-pricing-tier.md
1008-
- name: Set a daily cap
1009-
href: logs/daily-cap.md
10101003
- name: Manage tables
10111004
displayName: Azure Monitor Logs tables
10121005
items:

articles/azure-signalr/signalr-concept-disaster-recovery.md

Lines changed: 86 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ ms.devlang: csharp
88
ms.custom: devx-track-csharp
99
ms.date: 03/01/2019
1010
ms.author: lianwei
11+
zone_pivot_group_filename: azure-signalr/zone-pivot-groups.json
12+
zone_pivot_groups: azure-signalr-service-mode
1113
---
1214
# Resiliency and disaster recovery in Azure SignalR Service
1315

@@ -48,10 +50,9 @@ Multiple SignalR service instances are supported on both app servers and Azure F
4850

4951
Once you have SignalR service and app servers/Azure Functions created in each region, you can configure your app servers/Azure Functions to connect to all SignalR service instances.
5052

51-
### Configure on app servers
52-
There are two ways you can do it:
53+
:::zone pivot="default-mode"
5354

54-
#### Through config
55+
### Through config
5556

5657
You should already know how to set SignalR service connection string through environment variables/app settings/web.cofig, in a config entry named `Azure:SignalR:ConnectionString`.
5758
If you have multiple endpoints, you can set them in multiple config entries, each in the following format:
@@ -63,7 +64,7 @@ Azure:SignalR:ConnectionString:<name>:<role>
6364
In the ConnectionString, `<name>` is the name of the endpoint and `<role>` is its role (primary or secondary).
6465
Name is optional but it's useful if you want to further customize the routing behavior among multiple endpoints.
6566

66-
#### Through code
67+
### Through code
6768

6869
If you prefer to store the connection strings somewhere else, you can also read them in your code and use them as parameters when calling `AddAzureSignalR()` (in ASP.NET Core) or `MapAzureSignalR()` (in ASP.NET).
6970

@@ -94,9 +95,86 @@ You can configure multiple primary or secondary instances. If there are multiple
9495

9596
1. If there is at least one primary instance online, return a random primary online instance.
9697
2. If all primary instances are down, return a random secondary online instance.
98+
:::zone-end
99+
:::zone pivot="serverless-mode"
97100

98-
### Configure on Azure Functions
99-
See [this article](https://github.com/Azure/azure-functions-signalrservice-extension/blob/dev/docs/sharding.md#configuration-method).
101+
### For Azure Functions SignalR bindings
102+
103+
To enable multiple SignalR Service instances, you should:
104+
105+
1. Use `Persistent` transport type.
106+
107+
The default transport type is `Transient` mode. You should add the following entry to your `local.settings.json` file or the application setting on Azure.
108+
109+
```json
110+
{
111+
"AzureSignalRServiceTransportType":"Persistent"
112+
}
113+
```
114+
> [!NOTE]
115+
> When switching from `Transient` mode to `Persistent` mode, there may be JSON serialization behavior change, because under `Transient` mode, `Newtonsoft.Json` library is used to serialize arguments of hub methods, however, under `Persistent` mode, `System.Text.Json` library is used as default. `System.Text.Json` has some key differences in default behavior with `Newtonsoft.Json`. If you want to use `Newtonsoft.Json` under `Persistent` mode, you can add a configuration item: `"Azure:SignalR:HubProtocol":"NewtonsoftJson"` in `local.settings.json` file or `Azure__SignalR__HubProtocol=NewtonsoftJson` on Azure portal.
116+
117+
118+
2. Configure multiple SignalR Service endpoints entries in your configuration.
119+
120+
We use a [`ServiceEndpoint`](https://github.com/Azure/azure-signalr/blob/dev/src/Microsoft.Azure.SignalR.Common/Endpoints/ServiceEndpoint.cs) object to represent a SignalR Service instance. You can define a service endpoint with its `<EndpointName>` and `<EndpointType>` in the entry key, and the connection string in the entry value. The keys are in the following format:
121+
122+
```
123+
Azure:SignalR:Endpoints:<EndpointName>:<EndpointType>
124+
```
125+
126+
`<EndpointType>` is optional and defaults to `primary`. See samples below:
127+
128+
```json
129+
{
130+
"Azure:SignalR:Endpoints:EastUs":"<ConnectionString>",
131+
132+
"Azure:SignalR:Endpoints:EastUs2:Secondary":"<ConnectionString>",
133+
134+
"Azure:SignalR:Endpoints:WestUs:Primary":"<ConnectionString>"
135+
}
136+
```
137+
138+
> [!NOTE]
139+
> * When you configure Azure SignalR endpoints in the App Service on Azure portal, don't forget to replace `":"` with `"__"`, the double underscore in the keys. For reasons, see [Environment variables](/aspnet/core/fundamentals/configuration#environment-variables).
140+
>
141+
> * Connection string configured with the key `{ConnectionStringSetting}` (defaults to "AzureSignalRConnectionString") is also recognized as a primary service endpoint with empty name. But this configuration style is not recommended for multiple endpoints.
142+
143+
### For [Management SDK](./signalr-howto-use-management-sdk.md)
144+
#### Add multiple endpoints from config
145+
146+
Configure with key `Azure:SignalR:Endpoints` for SignalR Service connection string. The key should be in the format `Azure:SignalR:Endpoints:{Name}:{EndpointType}`, where `Name` and `EndpointType` are properties of the `ServiceEndpoint` object, and are accessible from code.
147+
148+
You can add multiple instance connection strings using the following `dotnet` commands:
149+
150+
```cmd
151+
dotnet user-secrets set Azure:SignalR:Endpoints:east-region-a <ConnectionString1>
152+
dotnet user-secrets set Azure:SignalR:Endpoints:east-region-b:primary <ConnectionString2>
153+
dotnet user-secrets set Azure:SignalR:Endpoints:backup:secondary <ConnectionString3>
154+
```
155+
156+
#### Add multiple endpoints from code
157+
158+
A `ServiceEndpoint` class describes the properties of an Azure SignalR Service endpoint.
159+
You can configure multiple instance endpoints when using Azure SignalR Management SDK through:
160+
```cs
161+
var serviceManager = new ServiceManagerBuilder()
162+
.WithOptions(option =>
163+
{
164+
options.Endpoints = new ServiceEndpoint[]
165+
{
166+
// Note: this is just a demonstration of how to set options.Endpoints
167+
// Having ConnectionStrings explicitly set inside the code is not encouraged
168+
// You can fetch it from a safe place such as Azure KeyVault
169+
new ServiceEndpoint("<ConnectionString0>"),
170+
new ServiceEndpoint("<ConnectionString1>", type: EndpointType.Primary, name: "east-region-a"),
171+
new ServiceEndpoint("<ConnectionString2>", type: EndpointType.Primary, name: "east-region-b"),
172+
new ServiceEndpoint("<ConnectionString3>", type: EndpointType.Secondary, name: "backup"),
173+
};
174+
})
175+
.BuildServiceManager();
176+
```
177+
:::zone-end
100178

101179
## Failover sequence and best practice
102180

@@ -127,7 +205,7 @@ After all existing clients disconnect, your system will be back to normal (Fig.1
127205

128206
There are two main patterns for implementing a cross region high available architecture:
129207

130-
1. The first one is to have a pair of app server and SignalR service instance taking all online traffic, and have another pair as a backup (called active/passive, illustrated in Fig.1).
208+
1. The first one is to have a pair of app server and SignalR service instance taking all online traffic, and have another pair as a backup (called active/passive, illustrated in Fig.1).
131209
2. The other one is to have two (or more) pairs of app servers and SignalR service instances, each one taking part of the online traffic and serves as backup for other pairs (called active/active, similar to Fig.3).
132210

133211
SignalR service can support both patterns, the main difference is how you implement app servers.
@@ -143,7 +221,7 @@ You need to handle such cases at client side to make it transparent to your end
143221

144222
Follow the steps to trigger the failover:
145223
1. In the Networking tab for the primary resource in the portal, **disable** public network access. If the resource has private network enabled, use *access control rules* to deny all the traffic.
146-
2. **Restart** the primary resource.
224+
2. **Restart** the primary resource.
147225

148226
## Next steps
149227

0 commit comments

Comments
 (0)