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
+
> [!INPORTANT]
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>` 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 --name "<your-unique-resource-name>" --resource-group "myResourceGroup" --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
+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
@@ -8,6 +8,6 @@ ms.author: lianwei
8
8
9
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
11
+
```azurecli
12
12
az group create --name "myResourceGroup" -l "EastUS"
> You can use the Windows cmd.exe command shell instead of a bash shell to run the commands in this tutorial.
27
+
25
28
If creating the project on a local machine, you'll need to install the dependencies for the language you're using:
26
29
27
30
# [C#](#tab/csharp)
@@ -43,7 +46,7 @@ If creating the project on a local machine, you'll need to install the dependenc
43
46
44
47
---
45
48
46
-
## Setup
49
+
## Setup
47
50
48
51
# [Local Azure CLI](#tab/LocalBash)
49
52
@@ -66,7 +69,21 @@ If creating the project on a local machine, you'll need to install the dependenc
66
69
67
70
### Create a Web PubSub instance
68
71
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 <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:
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.
70
87
71
88
### Get the connection string
72
89
@@ -83,7 +100,7 @@ Clients connect to the Azure Web PubSub service through the standard WebSocket p
83
100
* 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.
84
101
* The SDK package `Azure.Messaging.WebPubSub` helps to generate the JWT token.
85
102
86
-
```bash
103
+
```console
87
104
mkdir subscriber
88
105
cd subscriber
89
106
dotnet new console
@@ -140,17 +157,17 @@ Clients connect to the Azure Web PubSub service through the standard WebSocket p
140
157
141
158
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
159
143
-
1. Run the following command:
160
+
1. Run the following command replacing `<Web-PubSub-connection-string>` with the connection string you copied earlier:
144
161
145
-
```bash
146
-
dotnet run $connection_string"myHub1"
162
+
```console
163
+
dotnet run <Web-PubSub-connection-string> "myHub1"
147
164
```
148
165
149
166
# [JavaScript](#tab/javascript)
150
167
151
168
1. First, create a project directory named `subscriber` and install required dependencies:
152
169
153
-
```bash
170
+
```console
154
171
mkdir subscriber
155
172
cd subscriber
156
173
npm init -y
@@ -183,18 +200,18 @@ Clients connect to the Azure Web PubSub service through the standard WebSocket p
183
200
184
201
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
202
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`.
1. First, create a project directory named `subscriber` and install required dependencies:
196
213
197
-
```bash
214
+
```console
198
215
mkdir subscriber
199
216
cd subscriber
200
217
# Create venv
@@ -248,10 +265,10 @@ Clients connect to the Azure Web PubSub service through the standard WebSocket p
248
265
249
266
After the connection is established, your client will receive messages through the WebSocket connection. Use `await ws.recv()` to listen for incoming messages.
250
267
251
-
1. Run the following command:
268
+
1. Run the following command replacing `<Web-PubSub-connection-string>` with the connection string you copied earlier:
0 commit comments