Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
Data add serversideblazor sample Apr 19, 2019
Pages add serversideblazor sample Apr 19, 2019
Properties update Blazor sample to AddAzureSignalR() default May 13, 2019
Shared add serversideblazor sample Apr 19, 2019
wwwroot
App.razor add serversideblazor sample Apr 19, 2019
Program.cs add serversideblazor sample Apr 19, 2019
README.md update blazor readme May 13, 2019
ServerSideBlazor.csproj
Startup.cs update Blazor sample to AddAzureSignalR() default May 13, 2019
_Imports.razor
appsettings.json update Blazor sample to AddAzureSignalR() default May 13, 2019

README.md

Server-side Blazor with Azure SignalR Service

This sample is to show how to make Server-side Blazor work with Azure SignalR Service.

Prerequisites

  • Install .NET Core 3.0 SDK (Version >= 3.0.100-preview4-011136)
  • Provision an Azure SignalR Service instance

Set the connection string in the Secret Manager tool for .NET Core, and run this app.

dotnet restore
dotnet user-secrets set Azure:SignalR:ConnectionString "<your connection string>"
dotnet run

After running, you will see that the web server starts, makes connections to the Azure SignalR Service instance and creates an endpoint at http://localhost:5001/. Browser the page and click F12, you can find the connection to Azure SignalR Service is created. See snapshot

serversideblazor

Steps one by one

  1. Create Server-side Blazor project.
dotnet new blazorserverside 
  1. Add reference to Azure SignalR SDK
dotnet add package Microsoft.Azure.SignalR --version 1.1.0-preview1-10384
  1. Add a call to Azure SignalR Service in Startup.cs
public void ConfigureServices(IServiceCollection services)
{
    ...
    services.AddServerSideBlazor().AddSignalR().AddAzureSignalR();
    ...
}
  1. Configure Azure SignalR Service ConnectionString either in appsetting.json or with Secret Manager tool

Notes: Step 3 can be replaced by using hosting startup assemblies to SignalR SDK.

  1. Add configuration to turn on Azure SignalR Service in appsetting.json
  "Azure": {
    "SignalR": {
      "Enabled": true,
      "ConnectionString": <your-connection-string>
    }
  }
  1. Assign hosting startup assembly to use Azure SignalR SDK. Edit launchSettings.json and add a configuration like below inside environmentVariables.
"environmentVariables": {
    ...,
    "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.Azure.SignalR"
  }
You can’t perform that action at this time.