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
By default, the generated project includes a _host.json_ file that contains the extension bundles that include the SignalR extension. For more information about extension bundles, see [Register Azure Functions binding extensions](../azure-functions/functions-bindings-register.md#extension-bundles).
92
94
@@ -211,79 +213,90 @@ When the chat app first opens in the browser, it requires valid connection crede
211
213
212
214
This functiontakes the SignalR connection information from the input binding and returns it to the client in the HTTP response body. The SignalR client uses this information to connect to the Azure SignalR Service instance.
213
215
216
+
---
217
+
214
218
[Having issues? Let us know.](https://aka.ms/asrs/qsauth)
215
219
216
220
### Create a function to send chat messages
217
221
218
222
The web app also requires an HTTP API to send chat messages. Create an HTTP trigger functionthat sends messages to all connected clients that use Azure SignalR Service:
219
223
220
-
1. From the root project folder, create an HTTP trigger functionnamed`sendMessage` from the template by using the following command:
224
+
# [Model v4](#tab/nodejs-v4)
225
+
1. From the root project folder, create an HTTP trigger functionnamed`sendMessage` from the template by using the following command:
221
226
222
-
```bash
223
-
func new --name sendMessage --template "Http trigger"
224
-
```
227
+
```bash
228
+
func new --name sendMessage --template "Http trigger"
229
+
```
225
230
226
-
1. To configure bindings for the function, replace the content of _sendMessage/function.json_ with the following code:
231
+
# [Model v3](#tab/nodejs-v3)
227
232
228
-
```json
229
-
{
230
-
"disabled": false,
231
-
"bindings": [
232
-
{
233
-
"authLevel": "anonymous",
234
-
"type": "httpTrigger",
235
-
"direction": "in",
236
-
"name": "req",
237
-
"route": "messages",
238
-
"methods": ["post"]
239
-
},
240
-
{
241
-
"type": "http",
242
-
"direction": "out",
243
-
"name": "res"
244
-
},
245
-
{
246
-
"type": "signalR",
247
-
"name": "$return",
248
-
"hubName": "default",
249
-
"direction": "out"
250
-
}
251
-
]
252
-
}
253
-
```
233
+
1. From the root project folder, create an HTTP trigger functionnamed`sendMessage` from the template by using the following command:
254
234
255
-
The preceding code makes two changes to the original file:
235
+
```bash
236
+
func new --name sendMessage --template "Http trigger"
237
+
```
238
+
239
+
1. To configure bindings for the function, replace the content of _sendMessage/function.json_ with the following code:
240
+
241
+
```json
242
+
{
243
+
"disabled": false,
244
+
"bindings": [
245
+
{
246
+
"authLevel": "anonymous",
247
+
"type": "httpTrigger",
248
+
"direction": "in",
249
+
"name": "req",
250
+
"route": "messages",
251
+
"methods": ["post"]
252
+
},
253
+
{
254
+
"type": "http",
255
+
"direction": "out",
256
+
"name": "res"
257
+
},
258
+
{
259
+
"type": "signalR",
260
+
"name": "$return",
261
+
"hubName": "default",
262
+
"direction": "out"
263
+
}
264
+
]
265
+
}
266
+
```
256
267
257
-
- It changes the route to `messages` and restricts the HTTP trigger to the `POST` HTTP method.
258
-
- It adds an Azure SignalR Service output binding that sends a message returned by the functionto all clients connected to an Azure SignalR Service hub named `default`.
268
+
The preceding code makes two changes to the original file:
259
269
260
-
1. Replace the content of _sendMessage/index.js_ with the following code:
270
+
- It changes the route to `messages` and restricts the HTTP trigger to the `POST` HTTP method.
271
+
- It adds an Azure SignalR Service output binding that sends a message returned by the functionto all clients connected to an Azure SignalR Service hub named `default`.
This functiontakes the body from the HTTP request and sends it to clients connected to Azure SignalR Service. It invokes a functionnamed`newMessage` on each client.
295
+
This functiontakes the body from the HTTP request and sends it to clients connected to Azure SignalR Service. It invokes a functionnamed`newMessage` on each client.
283
296
284
-
The functioncanread 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.
297
+
The functioncanread 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.
285
298
286
-
1. Save the file.
299
+
1. Save the file.
287
300
288
301
[Having issues? Let us know.](https://aka.ms/asrs/qsauth)
0 commit comments