Skip to content

Commit bf6aab0

Browse files
committed
Chnage code labels and replace variable with placeholders
1 parent 8346378 commit bf6aab0

File tree

5 files changed

+54
-35
lines changed

5 files changed

+54
-35
lines changed

articles/azure-web-pubsub/includes/cli-awps-connstr.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ ms.date: 08/06/2021
66
ms.author: lianwei
77
---
88

9-
> [!Important]
9+
> [!INPORTANT]
1010
> A connection string includes the authorization information required for your application to access Azure Web PubSub service. The access key inside the connection string is similar to a root password for your service. In production environments, always be careful to protect your access keys. Use Azure Key Vault to manage and rotate your keys securely. Avoid distributing access keys to other users, hard-coding them, or saving them anywhere in plain text that is accessible to others. Rotate your keys if you believe they may have been compromised.
1111
12-
Use the Azure CLI [az webpubsub key](/cli/azure/webpubsub#az-webpubsub-key) command to get the **ConnectionString** of the service.
12+
Use the Azure CLI [az webpubsub key](/cli/azure/webpubsub#az-webpubsub-key) command to get the **ConnectionString** of the service. Replace the `<your-unique-resource-name>` with the name of your Azure Web PubSub instance.
1313

14-
```azurecli-interactive
15-
$connection-string=(az webpubsub key show --name "<your-unique-resource-name>" --resource-group "myResourceGroup" --query primaryConnectionString)
14+
```azurecli
15+
az webpubsub key show --name "<your-unique-resource-name>" --resource-group "myResourceGroup" --query primaryConnectionString --output tsv
1616
```
17+
18+
Copy the connection string to use later.

articles/azure-web-pubsub/includes/cli-awps-creation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Use the Azure CLI [az webpubsub create](/cli/azure/webpubsub#az-webpubsub-create
1717
> [!Important]
1818
> Each Web PubSub resource must have a unique name. Replace &lt;your-unique-resource-name&gt; with the name of your Web PubSub in the following examples.
1919
20-
```azurecli-interactive
20+
```azurecli
2121
az webpubsub create --name "<your-unique-resource-name>" --resource-group "myResourceGroup" --location "EastUS" --sku Free_F1
2222
```
2323

articles/azure-web-pubsub/includes/cli-awps-setup.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@ Follow these steps to set up the Azure CLI and your project environment.
1313

1414
1. Upgrade to the latest version of the Azure CLI.
1515

16-
```bash
16+
```azurecli
1717
az upgrade
1818
```
1919
2020
1. Install the Azure CLI extension for Web PubSub.
2121
22-
```bash
22+
```azurecli
2323
az extension add --name webpubsub
2424
```
2525
2626
1. Sign in to the Azure CLI. Following the prompts, enter your Azure credentials.
2727
28-
```bash
28+
```azurecli
2929
az login
3030
```
3131
3232
1. Create a resource group.
3333
34-
```bash
34+
```azurecli
3535
az group create --name myResourceGroup --location eastus
3636
```

articles/azure-web-pubsub/includes/cli-rg-creation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ ms.author: lianwei
88

99
A resource group is a logical container into which Azure resources are deployed and managed. Use the [az group create](/cli/azure/group#az-group-create) command to create a resource group named *myResourceGroup* in the *eastus* location.
1010

11-
```azurecli-interactive
11+
```azurecli
1212
az group create --name "myResourceGroup" -l "EastUS"
1313
```

articles/azure-web-pubsub/tutorial-pub-sub-messages.md

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: vicancy
55
ms.author: lianwei
66
ms.service: azure-web-pubsub
77
ms.topic: tutorial
8-
ms.date: 01/17/2023
8+
ms.date: 03/09/2023
99
---
1010

1111
# Tutorial: Publish and subscribe messages using WebSocket API and Azure Web PubSub service SDK
@@ -22,6 +22,9 @@ In this tutorial, you learn how to:
2222
2323
[!INCLUDE [azure-web-pubsub-tutorial-prerequisites](includes/cli-awps-prerequisites.md)]
2424

25+
>[!NOTE]
26+
> You can use the Windows cmd.exe command shell instead of a bash shell to run the commands in this tutorial.
27+
2528
If creating the project on a local machine, you'll need to install the dependencies for the language you're using:
2629

2730
# [C#](#tab/csharp)
@@ -43,7 +46,7 @@ If creating the project on a local machine, you'll need to install the dependenc
4346

4447
---
4548

46-
## Setup
49+
## Setup
4750

4851
# [Local Azure CLI](#tab/LocalBash)
4952

@@ -66,7 +69,21 @@ If creating the project on a local machine, you'll need to install the dependenc
6669

6770
### Create a Web PubSub instance
6871

69-
[!INCLUDE [Create a Web PubSub instance](includes/cli-awps-creation.md)]
72+
Use the Azure CLI [az webpubsub create](/cli/azure/webpubsub#az-webpubsub-create) command to create a Web PubSub in the resource group you've created. The following command creates a _Free_ Web PubSub resource under resource group *myResourceGroup* in *EastUS*:
73+
74+
> [!Important]
75+
> Each Web PubSub resource must have a unique name. Replace &lt;your-unique-resource-name&gt; with the name of your Web PubSub instance in the following command.
76+
77+
```azurecli
78+
az webpubsub create --name "<your-unique-resource-name>" --resource-group "myResourceGroup" --location "EastUS" --sku Free_F1
79+
```
80+
81+
The output of this command shows properties of the newly created resource. Take note of the two properties listed below:
82+
83+
* **Resource Name**: The name you provided to the `--name` parameter above.
84+
* **hostName**: In the example, the host name is `<your-unique-resource-name>.webpubsub.azure.com/`.
85+
86+
At this point, your Azure account is the only one authorized to perform any operations on this new resource.
7087

7188
### Get the connection string
7289

@@ -83,7 +100,7 @@ Clients connect to the Azure Web PubSub service through the standard WebSocket p
83100
* The package [Websocket.Client](https://github.com/Marfusios/websocket-client) is a third-party package supporting WebSocket connection. You can use any API/library that supports WebSocket to do so.
84101
* The SDK package `Azure.Messaging.WebPubSub` helps to generate the JWT token.
85102

86-
```bash
103+
```console
87104
mkdir subscriber
88105
cd subscriber
89106
dotnet new console
@@ -140,17 +157,17 @@ Clients connect to the Azure Web PubSub service through the standard WebSocket p
140157

141158
After the connection is established, your client receives messages through the WebSocket connection. The client uses `client.MessageReceived.Subscribe(msg => ...));` to listen for incoming messages.
142159

143-
1. Run the following command:
160+
1. Run the following command replacing `<Web-PubSub-connection-string>` with the connection string you copied earlier:
144161

145-
```bash
146-
dotnet run $connection_string "myHub1"
162+
```console
163+
dotnet run <Web-PubSub-connection-string> "myHub1"
147164
```
148165

149166
# [JavaScript](#tab/javascript)
150167

151168
1. First, create a project directory named `subscriber` and install required dependencies:
152169

153-
```bash
170+
```console
154171
mkdir subscriber
155172
cd subscriber
156173
npm init -y
@@ -183,18 +200,18 @@ Clients connect to the Azure Web PubSub service through the standard WebSocket p
183200

184201
After the connection is established, your client receives messages through the WebSocket connection. The client uses `client.MessageReceived.Subscribe(msg => ...));` to listen for incoming messages.
185202

186-
1. Run the following command:
203+
1. Run the following command replacing `<Web-PubSub-connection-string>` with the connection string you copied earlier. If you are using Windows, you can use `set` instead of `export`.
187204

188-
```bash
189-
export WebPubSubConnectionString=$connection_string
190-
node subscribe
205+
```console
206+
export WebPubSubConnectionString=<Web-PubSub-connection-string>
207+
node subscribe.js
191208
```
192209

193210
# [Python](#tab/python)
194211

195212
1. First, create a project directory named `subscriber` and install required dependencies:
196213

197-
```bash
214+
```console
198215
mkdir subscriber
199216
cd subscriber
200217
# Create venv
@@ -248,10 +265,10 @@ Clients connect to the Azure Web PubSub service through the standard WebSocket p
248265

249266
After the connection is established, your client will receive messages through the WebSocket connection. Use `await ws.recv()` to listen for incoming messages.
250267

251-
1. Run the following command:
268+
1. Run the following command replacing `<Web-PubSub-connection-string>` with the connection string you copied earlier:
252269

253-
```bash
254-
python subscribe.py $connection_string "myHub1"
270+
```console
271+
python subscribe.py <Web-PubSub-connection-string> "myHub1"
255272
```
256273

257274
# [Java](#tab/java)
@@ -379,7 +396,7 @@ Create a publisher using the Azure Web PubSub SDK to publish a message to the co
379396

380397
1. First, create a project directory named `publisher` and install required dependencies:
381398

382-
```bash
399+
```console
383400
mkdir publisher
384401
cd publisher
385402
dotnet new console
@@ -420,7 +437,7 @@ Create a publisher using the Azure Web PubSub SDK to publish a message to the co
420437

421438
1. Send a message by running the command:
422439

423-
```bash
440+
```console
424441
dotnet run $connection_string "myHub1" "Hello World"
425442
```
426443

@@ -434,7 +451,7 @@ Create a publisher using the Azure Web PubSub SDK to publish a message to the co
434451

435452
1. First, create a project directory named `publisher` and install required dependencies:
436453

437-
```bash
454+
```console
438455
mkdir publisher
439456
cd publisher
440457
npm init -y
@@ -456,24 +473,24 @@ Create a publisher using the Azure Web PubSub SDK to publish a message to the co
456473

457474
The `service.sendToAll()` call simply sends a message to all connected clients in a hub.
458475

459-
1. Send a message by running the command:
476+
1. Send a message by running the command. If you are using Windows, you can use `set` instead of `export`.
460477

461-
```bash
478+
```console
462479
export WebPubSubConnectionString=$connection_string
463480
node publish "Hello World"
464481
```
465482

466483
1. You can see that the previous subscriber received the message:
467484

468-
```text
485+
```console
469486
Message received: Hello World
470487
```
471488

472489
# [Python](#tab/python)
473490

474491
1. First, create a project directory named `publisher` and install required dependencies:
475492

476-
```bash
493+
```console
477494
mkdir publisher
478495
cd publisher
479496
# Create venv
@@ -510,7 +527,7 @@ Create a publisher using the Azure Web PubSub SDK to publish a message to the co
510527

511528
1. Run the following command:
512529

513-
```bash
530+
```console
514531
python publish.py $connection_string "myHub1" "Hello World"
515532
```
516533

@@ -616,4 +633,4 @@ Check other tutorials to dive further into how to use the service.
616633
> [Tutorial: Create a chatroom with Azure Web PubSub](./tutorial-build-chat.md)
617634
618635
> [!div class="nextstepaction"]
619-
> [Explore more Azure Web PubSub samples](https://aka.ms/awps/samples)
636+
> [Explore more Azure Web PubSub samples](https://aka.ms/awps/samples)

0 commit comments

Comments
 (0)