Skip to content

Commit 1e0c257

Browse files
committed
Update
1 parent 4ddaaa7 commit 1e0c257

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

articles/azure-signalr/signalr-tutorial-authenticate-azure-functions.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Your application will access a SignalR Service instance. Use the following step
5050
| **Pricing Tier** | Free |
5151
| **Service mode** | Serverless |
5252

53-
1. Select **Review + Create".
53+
1. Select **Review + Create**.
5454
1. Select **Create**.
5555

5656

@@ -89,26 +89,26 @@ By default, the generated project includes a *host.json* file containing the ext
8989

9090
### Configure application settings
9191

92-
When running and debugging the Azure Functions runtime locally, application settings are read by the function app from **local.settings.json**. Update this file with the connection strings of the SignalR Service instance and the storage account that you created earlier.
92+
When running and debugging the Azure Functions runtime locally, application settings are read by the function app from *local.settings.json*. Update this file with the connection strings of the SignalR Service instance and the storage account that you created earlier.
9393

9494
1. Replace the content of *local.settings.json* with the following code:
9595

9696
```json
9797
{
98-
"IsEncrypted": false,
99-
"Values": {
100-
"FUNCTIONS_WORKER_RUNTIME": "node",
101-
"AzureWebJobsStorage": "<your-storage-account-connection-string>",
102-
"AzureSignalRConnectionString": "<your-Azure-SignalR-connection-string>"
103-
}
98+
"IsEncrypted": false,
99+
"Values": {
100+
"FUNCTIONS_WORKER_RUNTIME": "node",
101+
"AzureWebJobsStorage": "<your-storage-account-connection-string>",
102+
"AzureSignalRConnectionString": "<your-Azure-SignalR-connection-string>"
103+
}
104104
}
105105
```
106106

107-
* Enter the Azure SignalR Service connection string into the' AzureSignalRConnectionString' setting.
107+
* Enter the Azure SignalR Service connection string into the `AzureSignalRConnectionString` setting.
108108

109109
Navigate to your SignalR Service in the Azure portal. In the **Settings** section, locate the **Keys** setting. Select the **Copy** button to the right of the connection string to copy it to your clipboard. You can use either the primary or secondary connection string.
110110

111-
* Enter the storage account connection string into the' AzureWebJobsStorage' setting.
111+
* Enter the storage account connection string into the `AzureWebJobsStorage` setting.
112112

113113
Navigate to your storage account in the Azure portal. In the **Security + networking** section, locate the **Access keys** setting. Select the **Copy** button to the right of the connection string to copy it to your clipboard. You can use either the primary or secondary connection string.
114114

@@ -117,12 +117,12 @@ When running and debugging the Azure Functions runtime locally, application sett
117117

118118
### Create a function to authenticate users to SignalR Service
119119

120-
When the chat app first opens in the browser, it requires valid connection credentials to connect to Azure SignalR Service. You'll create an HTTP triggered function named *negotiate* in your function app to return this connection information.
120+
When the chat app first opens in the browser, it requires valid connection credentials to connect to Azure SignalR Service. You'll create an HTTP triggered function named `negotiate` in your function app to return this connection information.
121121

122122
> [!NOTE]
123-
> This function must be named *negotiate* as the SignalR client requires an endpoint that ends in `/negotiate`.
123+
> This function must be named `negotiate` as the SignalR client requires an endpoint that ends in `/negotiate`.
124124

125-
1. From the root project folder, create the "negotiate" function from a built-in template with the following command.
125+
1. From the root project folder, create the `negotiate` function from a built-in template with the following command.
126126
```bash
127127
func new --template "SignalR negotiate HTTP trigger" --name negotiate
128128
```
@@ -166,7 +166,7 @@ When the chat app first opens in the browser, it requires valid connection crede
166166

167167

168168

169-
1. Open **negotiate/index.js** to view the body of the function.
169+
1. Open *negotiate/index.js* to view the body of the function.
170170

171171
```javascript
172172
module.exports = async function (context, req, connectionInfo) {
@@ -180,9 +180,9 @@ When the chat app first opens in the browser, it requires valid connection crede
180180

181181
### Create a function to send chat messages
182182

183-
The web app also requires an HTTP API to send chat messages. You'll create an HTTP triggered function named *sendMessage* that sends messages to all connected clients using SignalR Service.
183+
The web app also requires an HTTP API to send chat messages. You'll create an HTTP triggered function named `sendMessage` that sends messages to all connected clients using SignalR Service.
184184

185-
1. From the root project folder, create an HTTP trigger function named *sendMessage* from the template with the command:
185+
1. From the root project folder, create an HTTP trigger function named `sendMessage` from the template with the command:
186186
```bash
187187
func new --name sendMessage --template "Http trigger"
188188
```
@@ -215,7 +215,7 @@ The web app also requires an HTTP API to send chat messages. You'll create an HT
215215
}
216216
```
217217
Two changes are made to the original file:
218-
* Changes the route to `messages` and restricts the HTTP trigger to the **POST** HTTP method.
218+
* Changes the route to `messages` and restricts the HTTP trigger to the `POST` HTTP method.
219219
* Adds a SignalR Service output binding that sends a message returned by the function to all clients connected to a SignalR Service hub named `default`.
220220

221221
1. Replace the content of *sendMessage/index.js* with the following code:
@@ -241,7 +241,7 @@ The web app also requires an HTTP API to send chat messages. You'll create an HT
241241

242242
This function takes the body from the HTTP request and sends it to clients connected to SignalR Service, invoking a function named `newMessage` on each client.
243243

244-
The function can read the sender's identity and can accept a *recipient* value in the message body to allow you to send a message privately to a single user. You'll use these functionalities later in the tutorial.
244+
The function can read the sender's identity and can accept a `recipient` value in the message body to allow you to send a message privately to a single user. You'll use these functionalities later in the tutorial.
245245

246246
1. Save the file.
247247

@@ -254,14 +254,14 @@ The chat application's UI is a simple single-page application (SPA) created with
254254
1. Create a new folder named *content* in the root directory of your function project.
255255
1. In the *content* folder, create a new file named *index.html*.
256256

257-
1. Copy and paste the content of **[index.html](https://github.com/aspnet/AzureSignalR-samples/blob/da0aca70f490f3d8f4c220d0c88466b6048ebf65/samples/ServerlessChatWithAuth/content/index.html)** to your file. Save the file.
257+
1. Copy and paste the content of [index.html](https://github.com/aspnet/AzureSignalR-samples/blob/da0aca70f490f3d8f4c220d0c88466b6048ebf65/samples/ServerlessChatWithAuth/content/index.html) to your file. Save the file.
258258

259-
1. From the root project folder, create an HTTP trigger function named *index* from the template with the command:
259+
1. From the root project folder, create an HTTP trigger function named `index` from the template with the command:
260260
```bash
261261
func new --name index --template "Http trigger"
262262
```
263263

264-
1. Modify the content of **index/index.js** to the following:
264+
1. Modify the content of `index/index.js` to the following:
265265
```js
266266
const fs = require('fs');
267267

@@ -279,7 +279,7 @@ The chat application's UI is a simple single-page application (SPA) created with
279279
```
280280
The function reads the static web page and returns it to the user.
281281

282-
1. Open **index/function.json**, change the **authLevel** of the bindings to **anonymous**. Now the whole file looks like this:
282+
1. Open *index/function.json*, change the `authLevel` of the bindings to `anonymous`. Now the whole file looks like this:
283283
```json
284284
{
285285
"bindings": [
@@ -321,11 +321,11 @@ You have been running the function app and chat application locally. You'll now
321321

322322
### Configure function app for authentication
323323

324-
So far, the chat app works anonymously. In Azure, you'll use [App Service Authentication](../app-service/overview-authentication-authorization.md) to authenticate the user. The user ID or username of the authenticated user is passed to the *SignalRConnectionInfo* binding to generate connection information authenticated as the user.
324+
So far, the chat app works anonymously. In Azure, you'll use [App Service Authentication](../app-service/overview-authentication-authorization.md) to authenticate the user. The user ID or username of the authenticated user is passed to the `SignalRConnectionInfo` binding to generate connection information authenticated as the user.
325325

326326
1. Open *negotiate/function.json*.
327327

328-
1. Insert a *userId* property to the *SignalRConnectionInfo* binding with value `{headers.x-ms-client-principal-name}`. This value is a [binding expression](../azure-functions/functions-triggers-bindings.md) that sets the user name of the SignalR client to the name of the authenticated user. The binding should now look like this.
328+
1. Insert a `userId` property to the `SignalRConnectionInfo` binding with value `{headers.x-ms-client-principal-name}`. This value is a [binding expression](../azure-functions/functions-triggers-bindings.md) that sets the user name of the SignalR client to the name of the authenticated user. The binding should now look like this.
329329

330330
```json
331331
{
@@ -347,7 +347,7 @@ Deploy the function app to Azure with the following command:
347347
func azure functionapp publish <your-function-app-name> --publish-local-settings
348348
```
349349

350-
The *--publish-local-settings* option publishes your local settings from the *local.settings.json* file to Azure, so you don't need to configure them in Azure again.
350+
The `--publish-local-settings` option publishes your local settings from the *local.settings.json* file to Azure, so you don't need to configure them in Azure again.
351351

352352

353353
### Enable App Service Authentication

0 commit comments

Comments
 (0)