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-quickstart-dotnet-core.md
+12-23Lines changed: 12 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,20 +5,19 @@ author: vicancy
5
5
ms.service: signalr
6
6
ms.devlang: csharp
7
7
ms.topic: quickstart
8
-
ms.custom: devx-track-csharp, mode-other
9
-
ms.date: 09/28/2020
8
+
ms.date: 08/03/2022
10
9
ms.author: lianwei
11
10
---
12
11
13
12
# Quickstart: Create a chat room by using SignalR Service
14
13
15
-
Azure SignalR Service is an Azure service that helps developers easily build web applications with real-time features. This service was originally based on [SignalR for ASP.NET Core 2.1](/aspnet/core/signalr/introduction?preserve-view=true&view=aspnetcore-2.1), but now supports later versions.
14
+
Azure SignalR Service is an Azure service that helps developers easily build web applications with real-time features.
16
15
17
-
This article shows you how to get started with the Azure SignalR Service. In this quickstart, you'll create a chat application by using an ASP.NET Core MVC web app. This app will make a connection with your Azure SignalR Service resource to enable real-time content updates. You'll host the web application locally and connect with multiple browser clients. Each client will be able to push content updates to all other clients.
16
+
This article shows you how to get started with the Azure SignalR Service. In this quickstart, you'll create a chat application by using an ASP.NET Core MVC web app. This app will make a connection with your Azure SignalR Service resource to enable real-time content updates. You'll host the web application locally and connect with multiple browser clients. Each client will be able to push content updates to all other clients.
18
17
19
18
You can use any code editor to complete the steps in this quickstart. One option is [Visual Studio Code](https://code.visualstudio.com/), which is available on the Windows, macOS, and Linux platforms.
20
19
21
-
The code for this tutorial is available for download in the [AzureSignalR-samples GitHub repository](https://github.com/aspnet/AzureSignalR-samples/tree/master/samples/ChatRoom). Also, you can create the Azure resources used in this quickstart by following [Create a SignalR Service script](scripts/signalr-cli-create-service.md).
20
+
The code for this tutorial is available for download in the [AzureSignalR-samples GitHub repository](https://github.com/aspnet/AzureSignalR-samples/tree/master/samples/ChatRoom). You can create the Azure resources used in this quickstart by following [Create a SignalR Service script](scripts/signalr-cli-create-service.md).
@@ -55,13 +52,11 @@ In this section, you use the [.NET Core command-line interface (CLI)](/dotnet/co
55
52
dotnet new mvc
56
53
```
57
54
58
-
Having issues? Try the [troubleshooting guide](signalr-howto-troubleshoot-guide.md) or [let us know](https://aka.ms/asrs/qsnetcore).
59
-
60
55
## Add Secret Manager to the project
61
56
62
57
In this section, you'll add the [Secret Manager tool](/aspnet/core/security/app-secrets) to your project. The Secret Manager tool stores sensitive data for development work outside your project tree. This approach helps prevent the accidental sharing of app secrets in source code.
63
58
64
-
1. Open your *.csproj* file. Add a `DotNetCliToolReference` element to include *Microsoft.Extensions.SecretManager.Tools*. Also add a `UserSecretsId` element as shown in the following code for *chattest.csproj*, and save the file.
59
+
1. Open your *csproj* file. Add a `DotNetCliToolReference` element to include *Microsoft.Extensions.SecretManager.Tools*. Also add a `UserSecretsId` element as shown in the following code for *chattest.csproj*, and save the file.
65
60
66
61
```xml
67
62
<Project Sdk="Microsoft.NET.Sdk.Web">
@@ -79,8 +74,6 @@ In this section, you'll add the [Secret Manager tool](/aspnet/core/security/app-
79
74
</Project>
80
75
```
81
76
82
-
Having issues? Try the [troubleshooting guide](signalr-howto-troubleshoot-guide.md) or [let us know](https://aka.ms/asrs/qsnetcore).
83
-
84
77
## Add Azure SignalR to the web app
85
78
86
79
1. Add a reference to the `Microsoft.Azure.SignalR` NuGet package by running the following command:
@@ -95,11 +88,11 @@ Having issues? Try the [troubleshooting guide](signalr-howto-troubleshoot-guide.
95
88
dotnet restore
96
89
```
97
90
98
-
3. Add a secret named *Azure:SignalR:ConnectionString* to Secret Manager.
91
+
3. Add a secret named *Azure:SignalR:ConnectionString* to Secret Manager.
99
92
100
93
This secret will contain the connection string to access your SignalR Service resource. *Azure:SignalR:ConnectionString* is the default configuration key that SignalR looks for to establish a connection. Replace the value in the following command with the connection string for your SignalR Service resource.
101
94
102
-
You must run this command in the same directory as the *.csproj* file.
95
+
You must run this command in the same directory as the `csproj` file.
103
96
104
97
```dotnetcli
105
98
dotnet user-secrets set Azure:SignalR:ConnectionString "<Your connection string>"
@@ -120,7 +113,7 @@ Having issues? Try the [troubleshooting guide](signalr-howto-troubleshoot-guide.
120
113
}
121
114
```
122
115
123
-
By not passing a parameter to `AddAzureSignalR()`, this code uses the default configuration key for the SignalR Service resource connection string. The default configuration key is *Azure:SignalR:ConnectionString*.
116
+
Not passing a parameter to `AddAzureSignalR()` causes this code to use the default configuration key for the SignalR Service resource connection string. The default configuration key is *Azure:SignalR:ConnectionString*.
124
117
125
118
5. In *Startup.cs*, update the `Configure` method by replacing it with the following code.
126
119
@@ -138,7 +131,7 @@ Having issues? Try the [troubleshooting guide](signalr-howto-troubleshoot-guide.
138
131
139
132
### Add a hub class
140
133
141
-
In SignalR, a hub is a core component that exposes a set of methods that can be called from the client. In this section, you define a hub class with two methods:
134
+
In SignalR, a *hub* is a core component that exposes a set of methods that can be called by the client. In this section, you define a hub class with two methods:
142
135
143
136
* `Broadcast`: This method broadcasts a message to all clients.
144
137
* `Echo`: This method sends a message back to the caller.
@@ -175,9 +168,7 @@ The client user interface for this chat room app will consist of HTML and JavaSc
175
168
176
169
Copy the *css/site.css* file from the *wwwroot* folder of the [samples repository](https://github.com/aspnet/AzureSignalR-samples/tree/master/samples/ChatRoom/wwwroot). Replace your project's *css/site.css* with the one you copied.
177
170
178
-
Here's the main code of *index.html*:
179
-
180
-
Create a new file in the *wwwroot* directory named *index.html*, copy, and paste the following HTML into the newly created file:
171
+
Create a new file in the *wwwroot* directory named *index.html*, copy, and paste the following HTML into the newly created file.
181
172
182
173
```html
183
174
<!DOCTYPE html>
@@ -350,7 +341,6 @@ In this section, you'll add a development runtime environment for ASP.NET Core.
350
341
}
351
342
```
352
343
353
-
Having issues? Try the [troubleshooting guide](signalr-howto-troubleshoot-guide.md) or [let us know](https://aka.ms/asrs/qsnetcore).
354
344
355
345
## Build and run the app locally
356
346
@@ -385,7 +375,6 @@ Having issues? Try the [troubleshooting guide](signalr-howto-troubleshoot-guide.
385
375
386
376

387
377
388
-
Having issues? Try the [troubleshooting guide](signalr-howto-troubleshoot-guide.md) or [let us know](https://aka.ms/asrs/qsnetcore).
389
378
390
379
## Clean up resources
391
380
@@ -394,7 +383,7 @@ If you'll continue to the next tutorial, you can keep the resources created in t
394
383
If you're finished with the quickstart sample application, you can delete the Azure resources created in this quickstart to avoid charges.
395
384
396
385
> [!IMPORTANT]
397
-
> Deleting a resource group is irreversible and includes all the resources in that group. Make sure that you don't accidentally delete the wrong resource group or resources. If you created the resources for hosting this sample in an existing resource group that contains resources you want to keep, you can delete each resource individually from its blade instead of deleting the resource group.
386
+
> Deleting a resource group is irreversible and includes all the resources in that group. Make sure that you don't accidentally delete the wrong resource group or resources. If you created the resources this sample in an existing resource group that contains resources you want to keep, you can delete each resource individually from its blade instead of deleting the resource group.
398
387
399
388
Sign in to the [Azure portal](https://portal.azure.com) and select **Resource groups**.
0 commit comments