Adding Azure SignalR Service Dependencies
Learn to add dependencies in our SignalR application.
Steps to follow
Step 1: To add Azure SignalR Service dependencies to our application, we need to execute the following command inside SignalRHubs
project folder:
cd SignalR-on-.NET-6---the-complete-guide/Chapter-10/Part-02/LearningSignalR/SignalRHubs
dotnet add package Microsoft.Azure.SignalR
Step 2: Next, we can open the Program.cs
file of SignalRServer
project and replace the line with AddSignalR
call with the following:
cd SignalR-on-.NET-6---the-complete-guide/Chapter-10/Part-02/LearningSignalR/SignalRServer/Program.cs
builder.Services.AddSignalR().AddAzureSignalR();
Step 3: We can do the same in SignalRServer2
project. There are two ways of configuring it. The AddAzureSignalR
method can accept a string parameter representing the connection string of the Azure SignalR Service we have created earlier. But we can also leave it without the parameter. But to make it work, we will need to use the User Secrets tool inside the project.
If we don’t want to pass the connection string in the code of our Program.cs
file, we would need to execute the following command inside the project folder:
dotnet user-secrets init
Step 4: Then, we would need to execute the ...
Get hands-on with 1400+ tech skills courses.