Skip to content

Commit 07a503a

Browse files
authored
Fix some error
1 parent d0f5e6a commit 07a503a

File tree

5 files changed

+81
-81
lines changed

5 files changed

+81
-81
lines changed

articles/azure-web-pubsub/socket-io-serverless-overview.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ With the increasing adoption of serverless computing, we're introducing a new mo
2121
|Architecture|Use persistent connection for both servers and clients | Clients use persistent connections but servers use RESTful APIs and webhook event handlers in a stateless manner|
2222
|SDKs and Languages| Official JavaScript server SDKs together with [Extension library for Web PubSub for Socket.IO SDK](https://www.npmjs.com/package/@azure/web-pubsub-socket.io) is required; All compatible clients|No mandatory SDKs or languages. Use [Socket.IO Function binding](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.WebPubSubForSocketIO) to simplified integrate with Azure Function; All compatible clients|
2323
|Network Accessibility| The server doesn't need to expose network access as it proactively makes connection to the service|The server needs to expose network access to the service|
24-
|Feature supports|Most features are supported except some unsupported features: [Unsupported server APIs of Socket.IO](./socketio-supported-server-apis.md)|See list of supported features: [Supported functionality and RESTful APIs](./socketio-serverless-protocol.md#supported-functionality-and-restful-apis)|
24+
|Feature supports|Most features are supported except some unsupported features: [Unsupported server APIs of Socket.IO](./socket-io-supported-server-apis.md)|See list of supported features: [Supported functionality and RESTful APIs](./socketio-serverless-protocol.md#supported-functionality-and-restful-apis)|
2525

2626
## Next steps
2727

2828
This article provides you with an overview of the Serverless Mode of Web PubSub for Socket.IO.
2929

3030
> [!div class="nextstepaction"]
31-
> [Tutorial: Build chat app with Azure Function in Serverless Mode](./socketio-serverless-tutorial.md)
31+
> [Tutorial: Build chat app with Azure Function in Serverless Mode](./socket-io-serverless-tutorial.md)
3232
>
33-
> [Serverless Protocols](./socketio-serverless-protocol.md)
33+
> [Serverless Protocols](./socket-io-serverless-protocol.md)
3434
>
35-
> [Serverless Function Binding](./socketio-serverless-function-binding.md)
35+
> [Serverless Function Binding](./socket-io-serverless-function-binding.md)

articles/azure-web-pubsub/socket-io-serverless-protocol.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ms.topic: how-to
1111

1212
# Socket.IO Serverless Mode Specification (Preview)
1313

14-
This document describes the details of serverless support. As the Socket.IO supports including the serverless supports highly depends on the Web PubSub service's existing interface, it introduces many complicated transforming and mapping. For most users, we suggest using Azure Function bindings together with Serverless Mode. You can walk through a tutorial [Tutorial: Build chat app with Azure Function in Serverless Mode](./socketio-serverless-tutorial.md)
14+
This document describes the details of serverless support. As the Socket.IO supports including the serverless supports highly depends on the Web PubSub service's existing interface, it introduces many complicated transforming and mapping. For most users, we suggest using Azure Function bindings together with Serverless Mode. You can walk through a tutorial [Tutorial: Build chat app with Azure Function in Serverless Mode](./socket-io-serverless-tutorial.md)
1515

1616
## Lifetime workflow
1717

articles/azure-web-pubsub/socket-io-serverless-quickstart.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ We need to do two steps to deploy the sample app.
8888
func azure functionapp publish <function-app-name>
8989
```
9090

91-
- Configure the Web PubSub for Socket.IO to add a hub setting which can send request to the Function App. As per the limitation of Function App's Webhook provider, you need to get an extension key populated by Function. Get more details in [Trigger Binding](./socketio-serverless-function-binding.md#trigger-binding). And as we use identity-based authentication, in the hub settings, you need to assign the target resource, which is the clientId of the Service Principal created before.
91+
- Configure the Web PubSub for Socket.IO to add a hub setting which can send request to the Function App. As per the limitation of Function App's Webhook provider, you need to get an extension key populated by Function. Get more details in [Trigger Binding](./socket-io-serverless-function-binding.md#trigger-binding). And as we use identity-based authentication, in the hub settings, you need to assign the target resource, which is the clientId of the Service Principal created before.
9292

9393
```bash
9494
code=$(az functionapp keys list -g <resource-group> -n <function-name> --query systemKeys.socketio_extension -o tsv)
@@ -109,4 +109,4 @@ https://<function-endpoint>/api/index
109109
Next, you can follow the tutorial to write the app step by step:
110110

111111
> [!div class="nextstepaction"]
112-
> [Tutorial: Build chat app with Azure Function in Serverless Mode](./socketio-serverless-tutorial.md)
112+
> [Tutorial: Build chat app with Azure Function in Serverless Mode](./socket-io-serverless-tutorial.md)

articles/azure-web-pubsub/socket-io-serverless-tutorial-python.md

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,24 @@ You should follow the steps to initiate a local Azure Function project.
4747
func init SocketIOProject --worker-runtime python
4848
```
4949

50-
This command creates a Python-based Function project. And enter the folder `SocketIOProject` to run the following commands.
50+
This command creates a Python-based Function project. And enter the folder `SocketIOProject` to run the following commands.
5151

5252
1. Currently, the Function Bundle doesn't include Socket.IO Function Binding, so you need to manually add the package.
5353
5454
1. To eliminate the function bundle reference, edit the host.json file and remove the following lines.
5555
56-
```json
57-
"extensionBundle": {
58-
"id": "Microsoft.Azure.Functions.ExtensionBundle",
59-
"version": "[4.*, 5.0.0)"
60-
}
61-
```
56+
```json
57+
"extensionBundle": {
58+
"id": "Microsoft.Azure.Functions.ExtensionBundle",
59+
"version": "[4.*, 5.0.0)"
60+
}
61+
```
6262
6363
1. Run the command:
6464
65-
```bash
66-
func extensions install -p Microsoft.Azure.WebJobs.Extensions.WebPubSubForSocketIO -v 1.0.0-beta.4
67-
```
65+
```bash
66+
func extensions install -p Microsoft.Azure.WebJobs.Extensions.WebPubSubForSocketIO -v 1.0.0-beta.4
67+
```
6868
6969
1. Replace the content in `function_app.py` with the codes:
7070
@@ -109,18 +109,18 @@ This command creates a Python-based Function project. And enter the folder `Sock
109109
return func.HttpResponse(f.read(), mimetype='text/html')
110110
```
111111
112-
Here's the explanation of these functions:
112+
Here's the explanation of these functions:
113113

114-
- `publish_data`: This function updates the NASDAQ index every second with a random change and broadcasts it to connected clients with Socket.IO Output Binding.
114+
- `publish_data`: This function updates the NASDAQ index every second with a random change and broadcasts it to connected clients with Socket.IO Output Binding.
115115

116-
- `negotiate`: This function response a negotiation result to the client.
116+
- `negotiate`: This function response a negotiation result to the client.
117117

118-
- `index`: This function returns a static HTML page.
118+
- `index`: This function returns a static HTML page.
119119

120120

121-
Then add a `index.html` file
121+
Then add a `index.html` file
122122

123-
Create the index.html file with the content:
123+
Create the index.html file with the content:
124124

125125
```html
126126
<!DOCTYPE html>
@@ -234,28 +234,28 @@ Create the index.html file with the content:
234234
</html>
235235
```
236236
237-
The key part in the `index.html`:
237+
The key part in the `index.html`:
238238
239-
```javascript
240-
async function init() {
241-
const negotiateResponse = await fetch(`/api/negotiate`);
242-
if (!negotiateResponse.ok) {
243-
console.log("Failed to negotiate, status code =", negotiateResponse.status);
244-
return;
239+
```javascript
240+
async function init() {
241+
const negotiateResponse = await fetch(`/api/negotiate`);
242+
if (!negotiateResponse.ok) {
243+
console.log("Failed to negotiate, status code =", negotiateResponse.status);
244+
return;
245+
}
246+
const negotiateJson = await negotiateResponse.json();
247+
socket = io(negotiateJson.endpoint, {
248+
path: negotiateJson.path,
249+
query: { access_token: negotiateJson.token}
250+
});
251+
252+
socket.on('update', (index) => {
253+
updateIndexCore(index);
254+
});
245255
}
246-
const negotiateJson = await negotiateResponse.json();
247-
socket = io(negotiateJson.endpoint, {
248-
path: negotiateJson.path,
249-
query: { access_token: negotiateJson.token}
250-
});
251-
252-
socket.on('update', (index) => {
253-
updateIndexCore(index);
254-
});
255-
}
256-
```
256+
```
257257
258-
It first negotiates with the Function App to get the Uri and the path to the service. And register a callback to update index.
258+
It first negotiates with the Function App to get the Uri and the path to the service. And register a callback to update index.
259259
260260
## How to run the App locally
261261
@@ -288,27 +288,27 @@ Azure Functions requires a storage account to work even running in local. Choose
288288
289289
Update the project to use the Azure Blob Storage connection string.
290290
291-
```bash
292-
func settings add AzureWebJobsStorage "<storage-connection-string>"
293-
```
291+
```bash
292+
func settings add AzureWebJobsStorage "<storage-connection-string>"
293+
```
294294
295295
---
296296
297297
### Set up configuration of Web PubSub for Socket.IO
298298
299299
Add connection string to the Function APP:
300300
301-
```bash
302-
func settings add WebPubSubForSocketIOConnectionString "<connection string>"
303-
```
301+
```bash
302+
func settings add WebPubSubForSocketIOConnectionString "<connection string>"
303+
```
304304
305305
### Run Sample App
306306
307307
After tunnel tool is running, you can run the Function App locally:
308308
309-
```bash
310-
func start
311-
```
309+
```bash
310+
func start
311+
```
312312
313313
And visit the webpage at `http://localhost:7071/api/index`.
314314
@@ -318,4 +318,4 @@ And visit the webpage at `http://localhost:7071/api/index`.
318318
Next, you can try to use Bicep to deploy the app online with identity-based authentication:
319319
320320
> [!div class="nextstepaction"]
321-
> [Quickstart: Build chat app with Azure Function in Socket.IO Serverless Mode](./socketio-serverless-quickstart.md)
321+
> [Quickstart: Build chat app with Azure Function in Socket.IO Serverless Mode](./socket-io-serverless-quickstart.md)

articles/azure-web-pubsub/socket-io-serverless-tutorial.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ You should follow the steps to initiate a local Azure Function project.
4747
func init SocketIOProject --worker-runtime javascript --model V4
4848
```
4949

50-
This command creates a JavaScript project. And enter the folder `SocketIOProject` to run the following commands.
50+
This command creates a JavaScript project. And enter the folder `SocketIOProject` to run the following commands.
5151

5252
1. Currently, the Function Bundle doesn't include Socket.IO Function Binding, so you need to manually add the package.
5353
@@ -58,7 +58,7 @@ This command creates a JavaScript project. And enter the folder `SocketIOProject
5858
"id": "Microsoft.Azure.Functions.ExtensionBundle",
5959
"version": "[4.*, 5.0.0)"
6060
}
61-
```
61+
```
6262
6363
1. Run the command:
6464
@@ -72,7 +72,7 @@ This command creates a JavaScript project. And enter the folder `SocketIOProject
7272
func new --template "Http Trigger" --name negotiate
7373
```
7474
75-
Open the file in `src/functions/negotiate.js` and replace with the following code:
75+
Open the file in `src/functions/negotiate.js` and replace with the following code:
7676
7777
```js
7878
const { app, input } = require('@azure/functions');
@@ -98,15 +98,15 @@ Open the file in `src/functions/negotiate.js` and replace with the following cod
9898
});
9999
```
100100
101-
This step creates a function `negotiate` with Http Trigger and `SocketIONegotiation` output binding, which means you can use an Http call to trigger the function and return a negotiation result that generated by `SocketIONegotiation` binding.
101+
This step creates a function `negotiate` with Http Trigger and `SocketIONegotiation` output binding, which means you can use an Http call to trigger the function and return a negotiation result that generated by `SocketIONegotiation` binding.
102102
103103
1. Create a function for handing messages.
104104
105105
```bash
106106
func new --template "Http Trigger" --name message
107107
```
108108
109-
Open the file `src/functions/message.js` and replace with the following code:
109+
Open the file `src/functions/message.js` and replace with the following code:
110110
111111
```js
112112
const { app, output, trigger } = require('@azure/functions');
@@ -141,7 +141,7 @@ Open the file `src/functions/message.js` and replace with the following code:
141141
});
142142
```
143143
144-
This uses `SocketIOTrigger` to get triggered by a Socket.IO client message and use `SocketIO` binding to broadcast messages to namespace.
144+
This uses `SocketIOTrigger` to get triggered by a Socket.IO client message and use `SocketIO` binding to broadcast messages to namespace.
145145
146146
1. Create a function to return an index html for visiting.
147147
@@ -261,47 +261,47 @@ Azure Functions requires a storage account to work even running in local. Choose
261261
262262
1. Install the Azurite
263263
264-
```bash
265-
npm install -g azurite
266-
```
264+
```bash
265+
npm install -g azurite
266+
```
267267
268268
1. Start the Azurite storage emulator:
269269
270-
```bash
271-
azurite -l azurite -d azurite\debug.log
272-
```
270+
```bash
271+
azurite -l azurite -d azurite\debug.log
272+
```
273273
274274
1. Make sure the `AzureWebJobsStorage` in *local.settings.json* set to `UseDevelopmentStorage=true`.
275275
276276
#### [Azure Blob Storage](#tab/azure-blob-storage)
277277
278278
Update the project to use the Azure Blob Storage connection string.
279279
280-
```bash
281-
func settings add AzureWebJobsStorage "<storage-connection-string>"
282-
```
280+
```bash
281+
func settings add AzureWebJobsStorage "<storage-connection-string>"
282+
```
283283
284284
---
285285
286286
### Set up configuration of Web PubSub for Socket.IO
287287
288288
1. Add connection string to the Function APP:
289289
290-
```bash
291-
func settings add WebPubSubForSocketIOConnectionString "<connection string>"
292-
```
290+
```bash
291+
func settings add WebPubSubForSocketIOConnectionString "<connection string>"
292+
```
293293
294294
1. Add hub settings to the Web PubSub for Socket.IO
295295
296-
```bash
297-
az webpubsub hub create -n <resource name> -g <resource group> --hub-name hub --event-handler url-template="tunnel:///runtime/webhooks/socketio" user-event-pattern="*"
298-
```
296+
```bash
297+
az webpubsub hub create -n <resource name> -g <resource group> --hub-name hub --event-handler url-template="tunnel:///runtime/webhooks/socketio" user-event-pattern="*"
298+
```
299299
300300
The connection string can be obtained by the Azure CLI command
301301
302-
```azcli
303-
az webpubsub key show -g <resource group> -n <resource name>
304-
```
302+
```azcli
303+
az webpubsub key show -g <resource group> -n <resource name>
304+
```
305305
306306
The output contains `primaryConnectionString` and `secondaryConnectionString`, and either is available.
307307
@@ -323,15 +323,15 @@ An easiest way to achieve it's to use [Tunnel Tool](../azure-web-pubsub/howto-we
323323
awps-tunnel run --hub hub --connection "<connection string>" --upstream http://127.0.0.1:7071
324324
```
325325

326-
The `--upstream` is the url that local Azure Function exposes. The port may be different and you can check the output when starting the function in the next step.
326+
The `--upstream` is the url that local Azure Function exposes. The port may be different and you can check the output when starting the function in the next step.
327327

328328
### Run Sample App
329329

330330
After tunnel tool is running, you can run the Function App locally:
331331

332-
```bash
333-
func start
334-
```
332+
```bash
333+
func start
334+
```
335335

336336
And visit the webpage at `http://localhost:7071/api/index`.
337337

@@ -341,4 +341,4 @@ And visit the webpage at `http://localhost:7071/api/index`.
341341
Next, you can try to use Bicep to deploy the app online with identity-based authentication:
342342

343343
> [!div class="nextstepaction"]
344-
> [Quickstart: Build chat app with Azure Function in Socket.IO Serverless Mode](./socketio-serverless-quickstart.md)
344+
> [Quickstart: Build chat app with Azure Function in Socket.IO Serverless Mode](./socket-io-serverless-quickstart.md)

0 commit comments

Comments
 (0)