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).
83
92
@@ -117,57 +126,90 @@ When the chat app first opens in the browser, it requires valid connection crede
117
126
> [!NOTE]
118
127
> This function must be named `negotiate` because the SignalR client requires an endpoint that ends in `/negotiate`.
119
128
120
-
1. From the root project folder, create the `negotiate` function from a built-in template by using the following command:
121
-
122
-
```bash
123
-
func new --template "SignalR negotiate HTTP trigger" --name negotiate
124
-
```
125
-
126
-
1. Open _negotiate/function.json_ to view the function binding configuration.
127
-
128
-
The function contains an HTTP trigger binding to receive requests from SignalR clients. The function also contains a SignalR input binding to generate valid credentials for a client to connect to an Azure SignalR Service hub named `default`.
There's no `userId` property in the `signalRConnectionInfo` binding for local development. You'll add it later to set the username of a SignalR connection when you deploy the function app to Azure.
159
-
160
-
1. Close the _negotiate/function.json_ file.
161
-
162
-
1. Open _negotiate/index.js_ to view the body of the function:
This function takes 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.
129
+
# [Model v4](#tab/nodejs-v4)
130
+
131
+
1. From the root project folder, create the `negotiate` function from a built-in template by using the following command:
132
+
133
+
```bash
134
+
func new --template "HTTP trigger" --name negotiate
135
+
```
136
+
137
+
1. Open _src/functions/negotiate.js_, update the content as follows:
The function contains an HTTP trigger binding to receive requests from SignalR clients. The function also contains a SignalR input binding to generate valid credentials for a client to connect to an Azure SignalR Service hub named `default`.
161
+
162
+
This function takes the SignalR connection information from the input binding and returns it to the client in the HTTP response body..
163
+
164
+
There's no `userId` property in the `signalRConnectionInfo` binding for local development. You'll add it later to set the username of a SignalR connection when you deploy the function app to Azure.
165
+
166
+
# [Model v3](#tab/nodejs-v3)
167
+
168
+
1. Open _negotiate/function.json_ to view the function binding configuration.
169
+
170
+
The function contains an HTTP trigger binding to receive requests from SignalR clients. The function also contains a SignalR input binding to generate valid credentials for a client to connect to an Azure SignalR Service hub named `default`.
There's no `userId` property in the `signalRConnectionInfo` binding for local development. You'll add it later to set the username of a SignalR connection when you deploy the function app to Azure.
201
+
202
+
1. Close the _negotiate/function.json_ file.
203
+
204
+
1. Open _negotiate/index.js_ to view the body of the function:
205
+
206
+
```javascript
207
+
module.exports = async function (context, req, connectionInfo) {
208
+
context.res.body = connectionInfo;
209
+
};
210
+
```
211
+
212
+
This function takes 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.
171
213
172
214
[Having issues? Let us know.](https://aka.ms/asrs/qsauth)
0 commit comments