Skip to content

Commit 7347e9e

Browse files
authored
Merge pull request #314486 from v-thepet/sc10
Freshness Edit: Service Connector 10
2 parents b6692da + 6b7b2c2 commit 7347e9e

3 files changed

Lines changed: 127 additions & 66 deletions

File tree

Lines changed: 79 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,130 @@
11
---
2-
title: Integrate Azure Web PubSub with service connector
3-
description: Integrate Azure Web PubSub into your application with Service Connector
2+
title: Integrate Azure Web PubSub using Service Connector
3+
description: Learn how to connect Web PubSub to supported Azure compute services by using Service Connector.
44
author: maud-lv
55
ms.author: malev
66
ms.service: service-connector
77
ms.topic: how-to
8-
ms.date: 02/02/2024
8+
ms.date: 04/08/2026
9+
#customer intent: As an Azure app developer, I want to see authentication methods, environment variables, and sample code for using Service Connector with Web PubSub, so I can easily integrate Web PubSub into my apps.
10+
911
---
1012

11-
# Integrate Azure Web PubSub with service connector
13+
# Integrate Azure Web PubSub with Service Connector
1214

13-
This page shows supported authentication methods and clients, and shows sample code you can use to connect Azure Web PubSub to other cloud services using Service Connector. You might still be able to connect to App Configuration using other methods. This page also shows default environment variable names and values you get when you create the service connection.
15+
This article shows supported clients, authentication methods, and sample code you can use to connect Azure Web PubSub to other Azure services using Service Connector. The article also shows the default environment variables you need to create the service connections.
1416

1517
## Supported compute services
1618

17-
Service Connector can be used to connect the following compute services to Azure Web PubSub:
19+
You can use Service Connector to connect the following Azure compute services to Web PubSub:
1820

1921
- Azure App Service
2022
- Azure Container Apps
2123
- Azure Functions
2224
- Azure Kubernetes Service (AKS)
2325
- Azure Spring Apps
2426

25-
## Supported authentication types and client types
27+
## Supported clients and authentication types
28+
29+
The following client types support connecting Web PubSub to Azure compute services by using Service Connector:
30+
31+
- .NET
32+
- Java
33+
- Node.js
34+
- Python
35+
36+
>[!NOTE]
37+
>You might be able to connect to Web PubSub in other programming languages without using Service Connector.
38+
39+
All clients that support using Service Connector to connect Web PubSub to Azure compute services support all the following authentication types:
40+
41+
- System-assigned managed identity
42+
- User-assigned managed identity
43+
- Service principal
44+
- Connection string
45+
46+
> [!IMPORTANT]
47+
> The connection string authentication flow requires a high degree of trust in the application, and carries risks not present in other flows. You should use this flow only when more secure flows, such as managed identities, aren't viable.
48+
49+
## Default environment variables
2650

27-
The table below shows which combinations of authentication methods and clients are supported for connecting your compute service to Azure Web PubSub using Service Connector. A “Yes” indicates that the combination is supported, while a “No” indicates that it is not supported.
51+
Use the following connection details to connect supported Azure compute services to Web PubSub using the following authentication types:
2852

29-
| Client type | System-assigned managed identity | User-assigned managed identity | Secret/connection string | Service principal |
30-
|-------------|:--------------------------------:|:------------------------------:|:------------------------:|:-----------------:|
31-
| .NET | Yes | Yes | Yes | Yes |
32-
| Java | Yes | Yes | Yes | Yes |
33-
| Node.js | Yes | Yes | Yes | Yes |
34-
| Python | Yes | Yes | Yes | Yes |
53+
- [System-assigned managed identity](#system-assigned-managed-identity)
54+
- [User-assigned managed identity](#user-assigned-managed-identity)
55+
- [Service principal](#service-principal)
56+
- [Connection string](#connection-string)
3557

36-
This table indicates that all combinations of client types and authentication methods in the table are supported. Other client types are not supported to connect to Azure Web PubSub using Service Connector.
58+
In the examples, replace the following placeholders with the values for your Web PubSub account:
3759

38-
## Default environment variable names or application properties and sample code
60+
- `<name>`
61+
- `<client-ID>`
62+
- `<client-secret>`
63+
- `<access-key>`
64+
- `<tenant-ID>`
3965

40-
Use the environment variable names and application properties listed below, according to your connection's authentication type and client type, to connect compute services to Web PubSub using .NET, Java, Node.js, or Python. For each example below, replace the placeholder texts `<name>`, `<client-id>`, `<client-secret`, `<access-key>`, and `<tenant-id>` with your own resource name, client ID, client secret, access-key, and tenant ID. For more information about naming conventions, check the [Service Connector internals](concept-service-connector-internals.md#configuration-naming-convention) article.
66+
For more information about naming conventions, see [Configuration naming convention](concept-service-connector-internals.md#configuration-naming-convention).
4167

4268
### System-assigned managed identity
4369

70+
Use the following environment variables for system-assigned managed identity connections.
71+
4472
| Default environment variable name | Description | Sample value |
4573
| --------------------------------- | --------------------- | ------------------------------ |
4674
| AZURE_WEBPUBSUB_HOST | Azure Web PubSub host | `<name>.webpubsub.azure.com` |
4775

48-
#### Sample code
49-
50-
Refer to the steps and code below to connect to Azure Web PubSub using a system-assigned managed identity.
51-
[!INCLUDE [code for web pubsub](./includes/code-webpubsub-me-id.md)]
52-
5376
### User-assigned managed identity
5477

78+
Use the following environment variables for user-assigned managed identity connections.
79+
5580
| Default environment variable name | Description | Sample value |
5681
| --------------------------------- | -------------------------- | ------------------------------ |
5782
| AZURE_WEBPUBSUB_HOST | Azure Web PubSub host | `<name>.webpubsub.azure.com` |
58-
| AZURE_WEBPUBSUB_CLIENTID | Azure Web PubSub client ID | `<client-id>` |
83+
| AZURE_WEBPUBSUB_CLIENTID | Azure Web PubSub client ID | `<client-ID>` |
5984

60-
#### Sample code
85+
### Service principal
6186

62-
Refer to the steps and code below to connect to Azure Web PubSub using a user-assigned managed identity.
63-
[!INCLUDE [code for web pubsub](./includes/code-webpubsub-me-id.md)]
87+
Use the following environment variables for service principal connections.
88+
89+
| Default environment variable name | Description | Sample value |
90+
| --------------------------------- | ------------------------------ | ------------------------------ |
91+
| AZURE_WEBPUBSUB_HOST | Azure Web PubSub host | `<name>.webpubsub.azure.com` |
92+
| AZURE_WEBPUBSUB_CLIENTID | Azure Web PubSub client ID | `<client-ID>` |
93+
| AZURE_WEBPUBSUB_CLIENTSECRET | Azure Web PubSub client secret | `<client-secret>` |
94+
| AZURE_WEBPUBSUB_TENANTID | Azure Web PubSub tenant ID | `<tenant-ID>` |
6495

6596
### Connection string
6697

67-
> [!WARNING]
68-
> Microsoft recommends that you use the most secure authentication flow available. The authentication flow described in this procedure requires a very high degree of trust in the application, and carries risks that are not present in other flows. You should only use this flow when other more secure flows, such as managed identities, aren't viable.
98+
Use the following environment variables for connection string connections.
6999

70-
> [!div class="mx-tdBreakAll"]
71-
>
72-
> | Default environment variable name | Description | Sample value |
73-
> | --------------------------------- | ---------------------------------- | ----------------------------------------------------------------------------------- |
74-
> | AZURE_WEBPUBSUB_CONNECTIONSTRING | Azure Web PubSub connection string | `Endpoint=https://<name>.webpubsub.azure.com;AccessKey=<access-key>;Version=1.0;` |
100+
> [!IMPORTANT]
101+
> The connection string authentication flow requires a high degree of trust in the application, and carries risks not present in other flows. You should use this flow only when more secure flows, such as managed identities, aren't viable.
75102
76-
#### Sample code
103+
| Default environment variable name | Description | Sample value |
104+
| --------------|------------------- | ------------------------------- |
105+
| AZURE_WEBPUBSUB_CONNECTIONSTRING | Web PubSub connection string | `Endpoint=https://<name>.webpubsub.azure.com;AccessKey=<access-key>;Version=1.0;` |
77106

78-
Refer to the steps and code below to connect to Azure Web PubSub using a connection string.
79-
[!INCLUDE [code for web pubsub](./includes/code-webpubsub-secret.md)]
107+
## Sample connection code
80108

81-
### Service principal
109+
The following steps and sample code connect to Web PubSub using Service Connector with [managed identity, service principal](#misp), or [connection string](#connection-string) authentication. The code gets the variable values from the environment variables Service Connector sets.
82110

83-
| Default environment variable name | Description | Sample value |
84-
| --------------------------------- | ------------------------------ | ------------------------------ |
85-
| AZURE_WEBPUBSUB_HOST | Azure Web PubSub host | `<name>.webpubsub.azure.com` |
86-
| AZURE_WEBPUBSUB_CLIENTID | Azure Web PubSub client ID | `<client-id>` |
87-
| AZURE_WEBPUBSUB_CLIENTSECRET | Azure Web PubSub client secret | `<client-secret>` |
88-
| AZURE_WEBPUBSUB_TENANTID | Azure Web PubSub tenant ID | `<tenant-id>` |
111+
<a name="misp"></a>
112+
### Managed identity or service principal
89113

90-
#### Sample code
114+
Use the following steps and code to connect your services to Web PubSub using a managed identity or service principal. In the code, uncomment the lines for the authentication type you want to use: System-assigned managed identity, user-assigned managed identity, or service principal.
91115

92-
Refer to the steps and code below to connect to Azure Web PubSub using a service principal.
93116
[!INCLUDE [code for web pubsub](./includes/code-webpubsub-me-id.md)]
94117

95-
## Next steps
118+
### Connection string
119+
120+
Use the following steps and code to connect to Web PubSub using a connection string.
121+
122+
> [!IMPORTANT]
123+
> The connection string authentication flow requires a high degree of trust in the application, and carries risks not present in other flows. You should use this flow only when more secure flows, such as managed identities, aren't viable.
124+
125+
[!INCLUDE [code for web pubsub](./includes/code-webpubsub-secret.md)]
96126

97-
Read the article listed below to learn more about Service Connector.
127+
## Related content
98128

99-
> [!div class="nextstepaction"]
100-
> [Learn about Service Connector concepts](./concept-service-connector-internals.md)
129+
- [Service Connector concepts](concept-service-connector-internals.md)
130+
- [Configuration naming convention](concept-service-connector-internals.md#configuration-naming-convention)

articles/service-connector/includes/code-webpubsub-me-id.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,21 @@
22
author: wchigit
33
ms.service: service-connector
44
ms.topic: include
5-
ms.date: 10/25/2023
5+
ms.date: 04/07/2026
66
ms.author: wchi
77
---
88

99
### [.NET](#tab/dotnet)
1010

1111
1. Install dependencies.
12+
1213
```bash
1314
dotnet add package Azure.Identity
1415
dotnet add package Azure.Messaging.WebPubSub
1516
```
16-
1. Authenticate using `Azure.Identity` and get the endpoint URL from the environment variable added by Service Connector. When using the code below, uncomment the part of the code snippet for the authentication type you want to use.
17+
18+
1. Run the following code, uncommenting the part of the code snippet for the authentication type you want to use. The code authenticates using `Azure.Identity` and gets the Azure Web PubSub endpoint from the Service Connector environment variables.
19+
1720
```csharp
1821
using Azure.Identity;
1922
using Azure.Messaging.WebPubSub;
@@ -45,6 +48,7 @@ ms.author: wchi
4548
### [Java](#tab/java)
4649
4750
1. Add the following dependencies in your *pom.xml* file:
51+
4852
```xml
4953
<dependency>
5054
<groupId>com.azure</groupId>
@@ -57,7 +61,9 @@ ms.author: wchi
5761
<version>1.0.0</version>
5862
</dependency>
5963
```
60-
1. Authenticate using `azure-identity` and get the endpoint URL from the environment variable added by Service Connector. When using the code below, uncomment the part of the code snippet for the authentication type you want to use.
64+
65+
1. Run the following code, uncommenting the part of the code snippet for the authentication type you want to use. The code authenticates using `azure-identity` and gets the Web PubSub endpoint from the Service Connector environment variables.
66+
6167
```java
6268
// Uncomment the following lines corresponding to the authentication type you want to use.
6369
// For system-assigned managed identity.
@@ -89,11 +95,14 @@ ms.author: wchi
8995
### [Python](#tab/python)
9096
9197
1. Install dependencies.
98+
9299
```bash
93100
python -m pip install azure-identity
94101
python -m pip install azure-messaging-webpubsubservice
95102
```
96-
1. Authenticate using `azure-identity` and get the endpoint URL from the environment variable added by Service Connector. When using the code below, uncomment the part of the code snippet for the authentication type you want to use.
103+
104+
1. Run the following code, uncommenting the part of the code snippet for the authentication type you want to use. The code authenticates using `azure-identity` and gets the Web PubSub endpoint from the Service Connector environment variables.
105+
97106
```python
98107
from azure.identity import ManagedIdentityCredential, ClientSecretCredential
99108
from azure.messaging.webpubsubservice import WebPubSubServiceClient
@@ -121,11 +130,14 @@ ms.author: wchi
121130
### [NodeJS](#tab/nodejs)
122131
123132
1. Install dependencies.
133+
124134
```bash
125135
npm install @azure/web-pubsub
126136
npm install --save @azure/identity
127137
```
128-
1. Authenticate using `azure-identity` and get the endpoint URL from the environment variable added by Service Connector. When using the code below, uncomment the part of the code snippet for the authentication type you want to use.
138+
139+
1. Run the following code, uncommenting the part of the code snippet for the authentication type you want to use. The code authenticates using `@azure/identity` and gets the Azure Web PubSub endpoint from the Service Connector environment variables.
140+
129141
```javascript
130142
const { DefaultAzureCredential,ClientSecretCredential } = require("@azure/identity");
131143
const { WebPubSubServiceClient } = require("@azure/web-pubsub");
@@ -154,7 +166,8 @@ ms.author: wchi
154166
"<hub>"
155167
);
156168
```
169+
### [Other](#tab/none)
157170
171+
For other languages, you can use the connection configuration properties that Service Connector sets to the environment variables to connect to Azure Web PubSub.
158172
159-
### [Other](#tab/none)
160-
For other languages, you can use the connection configuration properties that Service Connector sets to the environment variables to connect to Azure Web PubSub. For environment variable details, see [Integrate Azure Web PubSub with Service Connector](../how-to-integrate-web-pubsub.md).
173+
---

articles/service-connector/includes/code-webpubsub-secret.md

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22
author: wchigit
33
ms.service: service-connector
44
ms.topic: include
5-
ms.date: 10/25/2023
5+
ms.date: 04/08/2026
66
ms.author: wchi
77
---
88

9-
109
### [.NET](#tab/dotnet)
1110

12-
1. Install dependencies.
11+
1. Install dependency.
12+
1313
```bash
1414
dotnet add package Azure.Messaging.WebPubSub
1515
```
1616

17-
1. Get the connection string from the environment variable added by Service Connector.
17+
1. Run the following code, getting the connection string from the Service Connector environment variables.
18+
1819
```csharp
1920
using Azure.Messaging.WebPubSub;
2021
@@ -25,15 +26,19 @@ ms.author: wchi
2526
```
2627

2728
### [Java](#tab/java)
29+
2830
1. Add the following dependencies in your *pom.xml* file:
31+
2932
```xml
3033
<dependency>
3134
<groupId>com.azure</groupId>
3235
<artifactId>azure-messaging-webpubsub</artifactId>
3336
<version>1.0.0</version>
3437
</dependency>
3538
```
36-
1. Get the connection string from the environment variable added by Service Connector.
39+
40+
1. Run the following code, getting the connection string from the Service Connector environment variables.
41+
3742
```java
3843
String connectionString = System.getenv("AZURE_WEBPUBSUB_CONNECTIONSTRING");
3944
@@ -43,12 +48,17 @@ ms.author: wchi
4348
.hub("<hub>")
4449
.buildClient();
4550
```
51+
4652
### [Python](#tab/python)
47-
1. Install dependencies.
53+
54+
1. Install dependency.
55+
4856
```bash
4957
python -m pip install azure-messaging-webpubsubservice
5058
```
51-
1. Get the connection string from the environment variable added by Service Connector.
59+
60+
1. Run the following code, getting the connection string from the Service Connector environment variables.
61+
5262
```python
5363
from azure.messaging.webpubsubservice import WebPubSubServiceClient
5464
@@ -57,12 +67,17 @@ ms.author: wchi
5767
# Replace "<hub>" with your hub name.
5868
service = WebPubSubServiceClient.from_connection_string(connection_string=connection_string, hub='<hub>')
5969
```
70+
6071
### [NodeJS](#tab/nodejs)
61-
1. Install dependencies.
72+
73+
1. Install dependency.
74+
6275
```bash
6376
npm install @azure/web-pubsub
6477
```
65-
1. Get the connection string from the environment variable added by Service Connector.
78+
79+
1. Run the following code, getting the connection string from the Service Connector environment variables.
80+
6681
```javascript
6782
const { WebPubSubServiceClient } = require("@azure/web-pubsub");
6883
@@ -73,4 +88,7 @@ ms.author: wchi
7388
```
7489
7590
### [Other](#tab/none)
76-
For other languages, you can use the connection configuration properties that Service Connector sets to the environment variables to connect to Azure Web PubSub. For environment variable details, see [Integrate Azure Web PubSub with Service Connector](../how-to-integrate-web-pubsub.md).
91+
For other languages, you can use the connection configuration properties that Service Connector sets to the environment variables to connect to Azure Web PubSub.
92+
93+
---
94+

0 commit comments

Comments
 (0)