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
Copy file name to clipboardExpand all lines: articles/azure-web-pubsub/includes/cli-awps-connstr.md
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,11 +6,13 @@ ms.date: 08/06/2021
6
6
ms.author: lianwei
7
7
---
8
8
9
-
> [!Important]
9
+
> [!IMPORTANT]
10
10
> 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.
11
11
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>` placeholder with the name of your Azure Web PubSub instance.
13
13
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 --resource-group myResourceGroup --name <your-unique-resource-name> --query primaryConnectionString --output tsv
Copy file name to clipboardExpand all lines: articles/azure-web-pubsub/includes/cli-awps-creation.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ Use the Azure CLI [az webpubsub create](/cli/azure/webpubsub#az-webpubsub-create
17
17
> [!Important]
18
18
> Each Web PubSub resource must have a unique name. Replace <your-unique-resource-name> with the name of your Web PubSub in the following examples.
Copy file name to clipboardExpand all lines: articles/azure-web-pubsub/includes/cli-rg-creation.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,8 +6,8 @@ ms.date: 08/06/2021
6
6
ms.author: lianwei
7
7
---
8
8
9
-
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.
9
+
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.
10
10
11
-
```azurecli-interactive
12
-
az group create --name "myResourceGroup" -l "EastUS"
11
+
```azurecli
12
+
az group create --name myResourceGroup --location EastUS
You can use the Windows cmd.exe command shell instead of a Bash shell to run the commands in this tutorial.
26
+
25
27
If creating the project on a local machine, you'll need to install the dependencies for the language you're using:
26
28
27
29
# [C#](#tab/csharp)
@@ -43,7 +45,7 @@ If creating the project on a local machine, you'll need to install the dependenc
43
45
44
46
---
45
47
46
-
## Setup
48
+
## Prepare your environment
47
49
48
50
# [Local Azure CLI](#tab/LocalBash)
49
51
@@ -55,7 +57,7 @@ If creating the project on a local machine, you'll need to install the dependenc
55
57
56
58
---
57
59
58
-
###Create a resource group
60
+
## Create a resource group
59
61
60
62
[!INCLUDE [Create a resource group](includes/cli-rg-creation.md)]
61
63
@@ -66,7 +68,20 @@ If creating the project on a local machine, you'll need to install the dependenc
66
68
67
69
### Create a Web PubSub instance
68
70
69
-
[!INCLUDE [Create a Web PubSub instance](includes/cli-awps-creation.md)]
71
+
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`:
72
+
73
+
Each Web PubSub resource must have a unique name. Replace <your-unique-resource-name> with the name of your Web PubSub instance in the following command.
The output of this command shows properties of the newly created resource. Take note of the two properties listed below:
80
+
81
+
***name**: The Web PubSub name you provided in the `--name` parameter above.
82
+
***hostName**: In the example, the host name is `<your-unique-resource-name>.webpubsub.azure.com/`.
83
+
84
+
At this point, your Azure account is the only one authorized to perform any operations on this new resource.
70
85
71
86
### Get the connection string
72
87
@@ -80,7 +95,7 @@ Clients connect to the Azure Web PubSub service through the standard WebSocket p
80
95
81
96
1. First, create a project directory named `subscriber` for this project and install required dependencies:
82
97
83
-
* 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.
98
+
* The package [Websocket.Client](https://github.com/Marfusios/websocket-client) is a third-party package supporting WebSocket connections. You can use any API/library that supports WebSocket.
84
99
* The SDK package `Azure.Messaging.WebPubSub` helps to generate the JWT token.
85
100
86
101
```bash
@@ -140,10 +155,10 @@ Clients connect to the Azure Web PubSub service through the standard WebSocket p
140
155
141
156
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.
142
157
143
-
1. Run the following command:
158
+
1. To start the subscriber, run the following command replacing `<Web-PubSub-connection-string>` with the connection string you copied earlier:
144
159
145
160
```bash
146
-
dotnet run $connection_string"myHub1"
161
+
dotnet run <Web-PubSub-connection-string>"myHub1"
147
162
```
148
163
149
164
# [JavaScript](#tab/javascript)
@@ -183,11 +198,11 @@ Clients connect to the Azure Web PubSub service through the standard WebSocket p
183
198
184
199
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.
185
200
186
-
1. Run the following command:
201
+
1. Run the following command replacing `<Web-PubSub-connection-string>` with the connection string you copied earlier. If you are using Windows command shell, you can use `set` instead of `export`.
@@ -248,10 +263,10 @@ Clients connect to the Azure Web PubSub service through the standard WebSocket p
248
263
249
264
After the connection is established, your client will receive messages through the WebSocket connection. Use `await ws.recv()` to listen for incoming messages.
250
265
251
-
1. Run the following command:
266
+
1. Run the following command replacing `<Web-PubSub-connection-string>` with the connection string you copied earlier:
@@ -265,7 +280,7 @@ Clients connect to the Azure Web PubSub service through the standard WebSocket p
265
280
266
281
1. Inside the `pubsub` directory, use Maven to create a new console app called `webpubsub-quickstart-subscriber`, then go to the *webpubsub-quickstart-subscriber* directory:
@@ -363,10 +378,10 @@ Clients connect to the Azure Web PubSub service through the standard WebSocket p
363
378
364
379
After connection is established, your client will receive messages through the WebSocket connection. Use `onMessage(String message)` to listen for incoming messages.
365
380
366
-
1. Navigate to the *webpubsub-quickstart-subscriber* directory and run the app with following command:
381
+
1. To start the subscriber app, go to the *webpubsub-quickstart-subscriber* directory and run the following command. Replace `<Web-PubSub-connection-string>` with the connection string you copied earlier.
@@ -418,15 +433,15 @@ Create a publisher using the Azure Web PubSub SDK to publish a message to the co
418
433
419
434
The `SendToAllAsync()` call simply sends a message to all connected clients in the hub.
420
435
421
-
1. Send a message by running the command:
436
+
1. Send a message by running the following command. Replace `<Web-PubSub-connection-string>` with the connection string you copied earlier.
422
437
423
438
```bash
424
-
dotnet run $connection_string "myHub1" "Hello World"
439
+
dotnet run <Web-PubSub-connection-string> "myHub1" "Hello World"
425
440
```
426
441
427
-
1. Check the command shell of the previous subscriber to see that it received the message:
442
+
1. Check the command shell of the subscriber to see that it received the message:
428
443
429
-
```text
444
+
```console
430
445
Message received: Hello World
431
446
```
432
447
@@ -456,16 +471,16 @@ Create a publisher using the Azure Web PubSub SDK to publish a message to the co
456
471
457
472
The `service.sendToAll()` call simply sends a message to all connected clients in a hub.
458
473
459
-
1. Send a message by running the command:
474
+
1. To send a message, run the following command replacing `<Web-PubSub-connection-string>` with the connection string you copied earlier. If you are using Windows command shell, you can use `set` instead of `export`.
1. Check the previous command shell to that the subscriber received the message:
518
533
519
-
```text
534
+
```console
520
535
Received message: Hello World
521
536
```
522
537
523
538
# [Java](#tab/java)
524
539
525
540
1. Go to the `pubsub` directory. Use Maven to create a publisher console app `webpubsub-quickstart-publisher` and go to the *webpubsub-quickstart-publisher* directory:
@@ -573,15 +588,15 @@ Create a publisher using the Azure Web PubSub SDK to publish a message to the co
573
588
574
589
The `sendToAll()` call sends a message to all connected clients in a hub.
575
590
576
-
1. Go to the *webpubsub-quickstart-publisher* directory and run the project using the following command:
591
+
1. To send a message, go to the *webpubsub-quickstart-publisher* directory and run the project using the following command. Replace the `<Web-PubSub-connection-string>` with the connection string you copied earlier.
0 commit comments