|
1 | 1 | --- |
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. |
4 | 4 | author: maud-lv |
5 | 5 | ms.author: malev |
6 | 6 | ms.service: service-connector |
7 | 7 | 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 | + |
9 | 11 | --- |
10 | 12 |
|
11 | | -# Integrate Azure Web PubSub with service connector |
| 13 | +# Integrate Azure Web PubSub with Service Connector |
12 | 14 |
|
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. |
14 | 16 |
|
15 | 17 | ## Supported compute services |
16 | 18 |
|
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: |
18 | 20 |
|
19 | 21 | - Azure App Service |
20 | 22 | - Azure Container Apps |
21 | 23 | - Azure Functions |
22 | 24 | - Azure Kubernetes Service (AKS) |
23 | 25 | - Azure Spring Apps |
24 | 26 |
|
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 |
26 | 50 |
|
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: |
28 | 52 |
|
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) |
35 | 57 |
|
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: |
37 | 59 |
|
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>` |
39 | 65 |
|
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). |
41 | 67 |
|
42 | 68 | ### System-assigned managed identity |
43 | 69 |
|
| 70 | +Use the following environment variables for system-assigned managed identity connections. |
| 71 | + |
44 | 72 | | Default environment variable name | Description | Sample value | |
45 | 73 | | --------------------------------- | --------------------- | ------------------------------ | |
46 | 74 | | AZURE_WEBPUBSUB_HOST | Azure Web PubSub host | `<name>.webpubsub.azure.com` | |
47 | 75 |
|
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 | | - |
53 | 76 | ### User-assigned managed identity |
54 | 77 |
|
| 78 | +Use the following environment variables for user-assigned managed identity connections. |
| 79 | + |
55 | 80 | | Default environment variable name | Description | Sample value | |
56 | 81 | | --------------------------------- | -------------------------- | ------------------------------ | |
57 | 82 | | 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>` | |
59 | 84 |
|
60 | | -#### Sample code |
| 85 | +### Service principal |
61 | 86 |
|
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>` | |
64 | 95 |
|
65 | 96 | ### Connection string |
66 | 97 |
|
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. |
69 | 99 |
|
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. |
75 | 102 |
|
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;` | |
77 | 106 |
|
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 |
80 | 108 |
|
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. |
82 | 110 |
|
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 |
89 | 113 |
|
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. |
91 | 115 |
|
92 | | -Refer to the steps and code below to connect to Azure Web PubSub using a service principal. |
93 | 116 | [!INCLUDE [code for web pubsub](./includes/code-webpubsub-me-id.md)] |
94 | 117 |
|
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)] |
96 | 126 |
|
97 | | -Read the article listed below to learn more about Service Connector. |
| 127 | +## Related content |
98 | 128 |
|
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) |
0 commit comments