Skip to content

Commit d074e2b

Browse files
Merge pull request #281716 from Akhilesh-microsoft/AWP/tutorial_pub_sub_messages
[AWP: tutorial-pub-sub-messages]: Verified the article for links and freshness, reviewed the content, verified/fixed editorial errors. Article seems good. Updated ms.date
2 parents 2164ffe + 7161406 commit d074e2b

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ ms.author: lianwei
66
ms.service: azure-web-pubsub
77
ms.custom: devx-track-azurecli
88
ms.topic: tutorial
9-
ms.date: 03/09/2023
9+
ms.date: 09/03/2024
1010
---
1111

1212
# Tutorial: Publish and subscribe messages using WebSocket API and Azure Web PubSub service SDK
1313

14-
The Azure Web PubSub service helps you to easily build real-time web messaging applications. In this tutorial, you'll learn how to subscribe to the service using WebSocket API and publish messages using the Web PubSub service SDK.
14+
The Azure Web PubSub service helps you easily build real-time web messaging applications. In this tutorial, you learn how to subscribe to the service using the WebSocket API and publish messages using the Web PubSub service SDK.
1515

1616
In this tutorial, you learn how to:
1717

1818
> [!div class="checklist"]
1919
> * Create a Web PubSub service instance
2020
> * Generate the full URL to establish the WebSocket connection
21-
> * Create a Web PubSub subscriber client to receive messages using standard WebSocket protocol
22-
> * Create a Web PubSub publisher client to publish messages using Web PubSub service SDK
21+
> * Create a Web PubSub subscriber client to receive messages using the standard WebSocket protocol
22+
> * Create a Web PubSub publisher client to publish messages using the Web PubSub service SDK
2323
2424
[!INCLUDE [azure-web-pubsub-tutorial-prerequisites](includes/cli-awps-prerequisites.md)]
2525

2626
You can use the Windows cmd.exe command shell instead of a Bash shell to run the commands in this tutorial.
2727

28-
If creating the project on a local machine, you'll need to install the dependencies for the language you're using:
28+
If you're creating the project on a local machine, you need to install the dependencies for the language you're using:
2929

3030
# [C#](#tab/csharp)
3131

@@ -69,15 +69,15 @@ If creating the project on a local machine, you'll need to install the dependenc
6969

7070
### Create a Web PubSub instance
7171

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`:
72+
To create a Web PubSub instance in the resource group you created, use the Azure CLI [az webpubsub create](/cli/azure/webpubsub#az-webpubsub-create) command. The following command creates a _Free_ Web PubSub resource under resource group `myResourceGroup` in `EastUS`:
7373

7474
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.
7575

7676
```azurecli
7777
az webpubsub create --resource-group myResourceGroup --name <your-unique-resource-name> --location EastUS --sku Free_F1
7878
```
7979

80-
The output of this command shows properties of the newly created resource. Take note of the two properties listed below:
80+
The output of this command shows properties of the newly created resource. Take note of the following roperties:
8181

8282
* **name**: The Web PubSub name you provided in the `--name` parameter above.
8383
* **hostName**: In the example, the host name is `<your-unique-resource-name>.webpubsub.azure.com/`.
@@ -107,7 +107,7 @@ Clients connect to the Azure Web PubSub service through the standard WebSocket p
107107
dotnet add package Azure.Messaging.WebPubSub --version 1.0.0
108108
```
109109

110-
1. Replace the code in the `Program.cs` with the following code that will connect to the service:
110+
1. Replace the code in the `Program.cs` with the following code that connects to the service:
111111

112112
```csharp
113113
using System;
@@ -199,7 +199,7 @@ Clients connect to the Azure Web PubSub service through the standard WebSocket p
199199
200200
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.
201201
202-
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`.
202+
1. Run the following command replacing `<Web-PubSub-connection-string>` with the connection string you copied earlier. If you're using Windows command shell, you can use `set` instead of `export`.
203203
204204
```bash
205205
export WebPubSubConnectionString=<Web-PubSub-connection-string>
@@ -389,7 +389,7 @@ Clients connect to the Azure Web PubSub service through the standard WebSocket p
389389
390390
## 2. Publish messages using service SDK
391391
392-
Create a publisher using the Azure Web PubSub SDK to publish a message to the connected client. For this project, you'll need to open another command shell.
392+
Create a publisher using the Azure Web PubSub SDK to publish a message to the connected client. For this project, you need to open another command shell.
393393
394394
# [C#](#tab/csharp)
395395
@@ -440,7 +440,7 @@ Create a publisher using the Azure Web PubSub SDK to publish a message to the co
440440
dotnet run <Web-PubSub-connection-string> "myHub1" "Hello World"
441441
```
442442
443-
1. Check the command shell of the subscriber to see that it received the message:
443+
1. Verify that the subscriber's command shell receives the message:
444444
445445
```console
446446
Message received: Hello World
@@ -458,7 +458,7 @@ Create a publisher using the Azure Web PubSub SDK to publish a message to the co
458458
459459
```
460460
461-
1. Use Azure Web PubSub SDK to publish a message to the service. Create a `publish.js` file with the below code:
461+
1. Use Azure Web PubSub SDK to publish a message to the service. Create a `publish.js` file with the following code:
462462
463463
```javascript
464464
const { WebPubSubServiceClient } = require('@azure/web-pubsub');
@@ -472,7 +472,7 @@ Create a publisher using the Azure Web PubSub SDK to publish a message to the co
472472
473473
The `service.sendToAll()` call simply sends a message to all connected clients in a hub.
474474
475-
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`.
475+
1. To send a message, run the following command replacing `<Web-PubSub-connection-string>` with the connection string you copied earlier. If you're using the Windows command shell, you can use `set` instead of `export`.
476476
477477
```bash
478478
export WebPubSubConnectionString=<Web-PubSub-connection-string>
@@ -501,7 +501,7 @@ Create a publisher using the Azure Web PubSub SDK to publish a message to the co
501501
502502
```
503503
504-
1. Use the Azure Web PubSub SDK to publish a message to the service. Create a `publish.py` file with the below code:
504+
1. Use the Azure Web PubSub SDK to publish a message to the service. Create a `publish.py` file with the following code:
505505
506506
```python
507507
import sys
@@ -538,7 +538,7 @@ Create a publisher using the Azure Web PubSub SDK to publish a message to the co
538538
539539
# [Java](#tab/java)
540540
541-
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:
541+
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:
542542
543543
```bash
544544
mvn archetype:generate --define interactiveMode=n --define groupId=com.webpubsub.quickstart --define artifactId=webpubsub-quickstart-publisher --define archetypeArtifactId=maven-archetype-quickstart --define archetypeVersion=1.4
@@ -589,7 +589,7 @@ Create a publisher using the Azure Web PubSub SDK to publish a message to the co
589589
590590
The `sendToAll()` call sends a message to all connected clients in a hub.
591591
592-
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.
592+
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.
593593
594594
```bash
595595
mvn compile & mvn package & mvn exec:java -Dexec.mainClass="com.webpubsub.quickstart.App" -Dexec.cleanupDaemonThreads=false -Dexec.args="<Web-PubSub-connection-string> 'myHub1' 'Hello World'"
@@ -611,7 +611,7 @@ You can delete the resources that you created in this quickstart by deleting the
611611
az group delete --name myResourceGroup --yes
612612
```
613613
614-
If you aren't planning to continue using Azure Cloud Shell, you can avoid accumulating costs by deleting the resource group that contains the associated the storage account. The resource group is named `cloud-shell-storage-<your-region>`. Run the following command, replacing `<CloudShellResourceGroup>` with the Cloud Shell group name.
614+
If you aren't planning to continue using Azure Cloud Shell, you can avoid accumulating costs by deleting the resource group that contains the associated the storage account. The resource group is named `cloud-shell-storage-<your-region>`. Run the following command, replacing `<CloudShellResourceGroup>` with the Cloud Shell group name.
615615
616616
617617
```azurecli

0 commit comments

Comments
 (0)