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
* Install [Visual Studio 2019](https://visualstudio.microsoft.com/vs/) (Version >= 16.3)
18
-
> Visual Studio 2019 Preview version also works which is releasing with latest Blazor Server App template targeting newer .Net Core version.
18
+
> Visual Studio 2019 Preview version also works which is releasing with latest Blazor Server app template targeting newer .Net Core version.
19
19
20
-
## Build a local chat room in Blazor Server App
20
+
## Build a local chat room in Blazor Server app
21
21
22
22
From Visual Studio 2019 version 16.2.0, Azure SignalR Service is build-in web app publish process, and manage dependencies between web app and SignalR service would be much more convenient. You can experience working on local SignalR in dev local environment and working on Azure SignalR Service for Azure App Service at the same time without any code changes.
23
23
@@ -335,46 +335,52 @@ From Visual Studio 2019 version 16.2.0, Azure SignalR Service is build-in web ap
335
335
}
336
336
```
337
337
338
-
1. Click `F5` to run the app. You'll be able to chat like below.
338
+
1. Click `F5` to run the app. You'll be able to chat like below.
339
339
340
-

340
+

341
341
342
342
## Publish to Azure App Service and migration to Azure SignalR Service
343
343
344
344
So far, the Blazor App is working on local SignalR and when deploy to Azure App Service, it's suggested to use [Azure SignalR Service](https://docs.microsoft.com/en-us/aspnet/core/signalr/scale?view=aspnetcore-3.1#azure-signalr-service) which allows for scaling up a Blazor Server app to a large number of concurrent SignalR connections. In addition, the SignalR service's global reach and high-performance data centers significantly aid in reducing latency due to geography.
345
345
346
346
> Note
347
-
> In Blazor server app, UI states are maintained at server side which means server sticky is required in this case. If there's single app server, server sticky is ensured by design. However, if there're multiple app servers, there's a chance that client negotiation and connection may go to different servers and leads to UI errors in Blazor app. So you need to enable server sticky like below in `appsettings.json`:
347
+
>
348
+
> In Blazor Server app, UI states are maintained at server side which means server sticky is required in this case. If there's single app server, server sticky is ensured by design. However, if there're multiple app servers, there's a chance that client negotiation and connection may go to different servers and leads to UI errors in Blazor app. So you need to enable server sticky like below in `appsettings.json`:
348
349
> ```json
349
350
> "Azure:SignalR:ServerStickyMode": "Required"
350
351
> ```
351
352
352
353
1. Right click the project and navigate to `Publish`.
353
354
354
355
* Target: Azure
355
-
* Specific target: All Azure App Service are supported.
356
+
* Specific target: All types of **Azure App Service** are supported.
356
357
* App Service: create a new one or select existing app service.
After publish profile created, you can see a recommended message under Service Dependencies. Click **Configure** to create new or select existing Azure SignalR Service in the panel.
363
+
After publish profile created, you can see a recommended message under **Service Dependencies**. Click **Configure** to create new or select existing Azure SignalR Service in the panel.
The service dependency will do things below to enable your app automatically switch to Azure SignalR Service when on Azure:
367
368
369
+
* Update [`HostingStartupAssembly`](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/platform-specific-configuration?view=aspnetcore-3.1) to use Azure SignalR Service.
368
370
* Add Azure SignalR Service Nuget package reference.
369
-
* Add configuration to make your app target selected Azure SignalR Service.
371
+
* Update profile properties to save the dependency settings.
372
+
* Configure secrets store depends on your choice.
373
+
* Add `appsettings` configuration to make your app target selected Azure SignalR Service.
Now it's ready to publish. And it'll auto browser the page after publishing completes.
374
380
> It may not immediately work in the first time visiting page due to Azure Web App deployment start up latency and try refresh the page to give some delay.
375
381
> Besides, you can use browser debugger mode with `F12` to validate the traffic has already redirect to Azure SignalR Service.
## Further topic: Enable Azure SignalR Service in local development
380
386
@@ -397,22 +403,24 @@ From Visual Studio 2019 version 16.2.0, Azure SignalR Service is build-in web ap
397
403
398
404
3. Configure Azure SignalR Service `ConnectionString` either in [appsetting.json](appsettings.json) or with [Secret Manager](https://docs.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-2.1&tabs=visual-studio#secret-manager) tool
399
405
400
-
> Notes: Step 3 can be replaced by using hosting startup assemblies to SignalR SDK.
406
+
> Note
407
+
>
408
+
> Step 3 can be replaced by using hosting startup assemblies to SignalR SDK.
401
409
>
402
410
> 1. Add configuration to turn on Azure SignalR Service in [appsetting.json](appsettings.json)
403
-
> ```js
404
-
>"Azure": {
405
-
>"SignalR": {
406
-
>"Enabled":true,
407
-
>"ConnectionString":<your-connection-string>
408
-
> }
409
-
> }
410
-
>```
411
+
> ```js
412
+
>"Azure": {
413
+
>"SignalR": {
414
+
>"Enabled":true,
415
+
>"ConnectionString":<your-connection-string>
416
+
>}
417
+
>}
418
+
>```
411
419
>
412
420
> 2. Assign hosting startup assembly to use Azure SignalR SDK. Edit [launchSettings.json](Properties/launchSettings.json) and add a configuration like below inside `environmentVariables`.
0 commit comments