Skip to content

Commit e8cee26

Browse files
authored
Merge pull request #222738 from ArchangelSDY/kv-shrpe
Add doc for azure web pubsub shared private link to key vault
2 parents 4d17f89 + 49794c3 commit e8cee26

10 files changed

+190
-0
lines changed

articles/azure-web-pubsub/howto-custom-domain.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,14 @@ $ curl -vvv https://contoso.example.com/api/health
166166

167167
It should return `200` status code without any certificate error.
168168

169+
## Key Vault in private network
170+
171+
If you have configured [Private Endpoint](../private-link/private-endpoint-overview.md) to your Key Vault, Azure Web PubSub Service cannot access the Key Vault via public network. You need to set up a [Shared Private Endpoint](./howto-secure-shared-private-endpoints-key-vault.md) to let Azure Web PubSub Service access your Key Vault via private network.
172+
173+
After you create a Shared Private Endpoint, you can create a custom certificate as usual. **You don't have to change the domain in Key Vault URI**. For example, if your Key Vault base URI is `https://contoso.vault.azure.net`, you still use this URI to configure custom certificate.
174+
175+
You don't have to explicitly allow Azure Web PubSub Service IPs in Key Vault firewall settings. For more info, see [Key Vault private link diagnostics](../key-vault/general/private-link-diagnostics.md).
176+
169177
## Next steps
170178

171179
+ [How to enable managed identity for Azure Web PubSub Service](howto-use-managed-identity.md)
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
---
2+
title: Access Key Vault in private network through Shared Private Endpoints
3+
titleSuffix: Azure Web PubSub Service
4+
description: How to access key vault in private network through Shared Private Endpoints
5+
author: ArchangelSDY
6+
ms.service: azure-web-pubsub
7+
ms.topic: article
8+
ms.date: 01/03/2023
9+
ms.author: dayshen
10+
---
11+
12+
# Access Key Vault in private network through Shared Private Endpoints
13+
14+
Azure Web PubSub Service can access your Key Vault in private network through Shared Private Endpoints. In this way you don't have to expose your Key Vault on public network.
15+
16+
:::image type="content" alt-text="Diagram showing architecture of shared private endpoint." source="media\howto-secure-shared-private-endpoints-key-vault\shared-private-endpoint-overview.png" :::
17+
18+
## Shared Private Link Resources Management
19+
20+
Private endpoints of secured resources that are created through Azure Web PubSub Service APIs are referred to as *shared private link resources*. This is because you're "sharing" access to a resource, such as an Azure Key Vault, that has been integrated with the [Azure Private Link service](https://azure.microsoft.com/services/private-link/). These private endpoints are created inside Azure Web PubSub Service execution environment and aren't directly visible to you.
21+
22+
> [!NOTE]
23+
> The examples in this article are based on the following assumptions:
24+
> * The resource ID of this Azure Web PubSub Service is _/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.SignalRService/webpubsub/contoso-webpubsub .
25+
> * The resource ID of Azure Key Vault is _/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.KeyVault/vaults/contoso-kv_.
26+
27+
The rest of the examples show how the *contoso-webpubsub* service can be configured so that its outbound calls to Key Vault go through a private endpoint rather than public network.
28+
29+
### Step 1: Create a shared private link resource to the Key Vault
30+
31+
#### [Azure portal](#tab/azure-portal)
32+
33+
1. In the Azure portal, go to your Azure Web PubSub Service resource.
34+
1. In the menu pane, select **Networking**. Switch to **Private access** tab.
35+
1. Click **Add shared private endpoint**.
36+
37+
:::image type="content" alt-text="Screenshot of shared private endpoints management." source="media\howto-secure-shared-private-endpoints-key-vault\portal-shared-private-endpoints-management.png" lightbox="media\howto-secure-shared-private-endpoints-key-vault\portal-shared-private-endpoints-management.png" :::
38+
39+
1. Fill in a name for the shared private endpoint.
40+
1. Select the target linked resource either by selecting from your owned resources or by filling a resource ID.
41+
1. Click **Add**.
42+
43+
:::image type="content" alt-text="Screenshot of adding a shared private endpoint." source="media\howto-secure-shared-private-endpoints-key-vault\portal-shared-private-endpoints-add.png" :::
44+
45+
1. The shared private endpoint resource will be in **Succeeded** provisioning state. The connection state is **Pending** approval at target resource side.
46+
47+
:::image type="content" alt-text="Screenshot of an added shared private endpoint." source="media\howto-secure-shared-private-endpoints-key-vault\portal-shared-private-endpoints-added.png" lightbox="media\howto-secure-shared-private-endpoints-key-vault\portal-shared-private-endpoints-added.png" :::
48+
49+
#### [Azure CLI](#tab/azure-cli)
50+
51+
You can make the following API call with the [Azure CLI](/cli/azure/) to create a shared private link resource:
52+
53+
```dotnetcli
54+
az rest --method put --uri https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.SignalRService/webpubsub/contoso-webpubsub/sharedPrivateLinkResources/kv-pe?api-version=2022-08-01-preview --body @create-pe.json
55+
```
56+
57+
The contents of the *create-pe.json* file, which represent the request body to the API, are as follows:
58+
59+
```json
60+
{
61+
"name": "contoso-kv",
62+
"properties": {
63+
"privateLinkResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.KeyVault/vaults/contoso-kv",
64+
"groupId": "vault",
65+
"requestMessage": "please approve"
66+
}
67+
}
68+
```
69+
70+
The process of creating an outbound private endpoint is a long-running (asynchronous) operation. As in all asynchronous Azure operations, the `PUT` call returns an `Azure-AsyncOperation` header value that looks like the following:
71+
72+
```plaintext
73+
"Azure-AsyncOperation": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.SignalRService/webpubsub/contoso-webpubsub/operationStatuses/c0786383-8d5f-4554-8d17-f16fcf482fb2?api-version=2022-08-01-preview"
74+
```
75+
76+
You can poll this URI periodically to obtain the status of the operation.
77+
78+
If you're using the CLI, you can poll for the status by manually querying the `Azure-AsyncOperationHeader` value,
79+
80+
```dotnetcli
81+
az rest --method get --uri https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.SignalRService/webpubsub/contoso-webpubsub/operationStatuses/c0786383-8d5f-4554-8d17-f16fcf482fb2?api-version=2022-08-01-preview
82+
```
83+
84+
Wait until the status changes to "Succeeded" before proceeding to the next steps.
85+
86+
-----
87+
88+
### Step 2a: Approve the private endpoint connection for the Key Vault
89+
90+
#### [Azure portal](#tab/azure-portal)
91+
92+
1. In the Azure portal, select the **Networking** tab of your Key Vault and navigate to **Private endpoint connections**. After the asynchronous operation has succeeded, there should be a request for a private endpoint connection with the request message from the previous API call.
93+
94+
:::image type="content" alt-text="Screenshot of the Azure portal, showing the Private endpoint connections pane." source="media\howto-secure-shared-private-endpoints-key-vault\portal-key-vault-approve-private-endpoint.png" :::
95+
96+
1. Select the private endpoint that Azure Web PubSub Service created. Click **Approve**.
97+
98+
Make sure that the private endpoint connection appears as shown in the following screenshot. It could take one to two minutes for the status to be updated in the portal.
99+
100+
:::image type="content" alt-text="Screenshot of the Azure portal, showing an Approved status on the Private endpoint connections pane." source="media\howto-secure-shared-private-endpoints-key-vault\portal-key-vault-approved-private-endpoint.png" :::
101+
102+
#### [Azure CLI](#tab/azure-cli)
103+
104+
1. List private endpoint connections.
105+
106+
```dotnetcli
107+
az network private-endpoint-connection list -n <key-vault-resource-name> -g <key-vault-resource-group-name> --type 'Microsoft.KeyVault/vaults'
108+
```
109+
110+
There should be a pending private endpoint connection. Note down its ID.
111+
112+
```json
113+
[
114+
{
115+
"id": "<id>",
116+
"location": "",
117+
"name": "",
118+
"properties": {
119+
"privateLinkServiceConnectionState": {
120+
"actionRequired": "None",
121+
"description": "Please approve",
122+
"status": "Pending"
123+
}
124+
}
125+
}
126+
]
127+
```
128+
129+
1. Approve the private endpoint connection.
130+
131+
```dotnetcli
132+
az network private-endpoint-connection approve --id <private-endpoint-connection-id>
133+
```
134+
135+
-----
136+
137+
### Step 2b: Query the status of the shared private link resource
138+
139+
It takes minutes for the approval to be propagated to Azure Web PubSub Service. You can check the state using either Azure portal or Azure CLI.
140+
141+
#### [Azure portal](#tab/azure-portal)
142+
143+
:::image type="content" alt-text="Screenshot of an approved shared private endpoint." source="media\howto-secure-shared-private-endpoints-key-vault\portal-shared-private-endpoints-approved.png" lightbox="media\howto-secure-shared-private-endpoints-key-vault\portal-shared-private-endpoints-approved.png" :::
144+
145+
#### [Azure CLI](#tab/azure-cli)
146+
147+
```dotnetcli
148+
az rest --method get --uri https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.SignalRService/webpubsub/contoso-webpubsub/sharedPrivateLinkResources/func-pe?api-version=2022-08-01-preview
149+
```
150+
151+
This would return a JSON, where the connection state would show up as "status" under the "properties" section.
152+
153+
```json
154+
{
155+
"name": "contoso-kv",
156+
"properties": {
157+
"privateLinkResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso/providers/Microsoft.KeyVault/vaults/contoso-kv",
158+
"groupId": "vaults",
159+
"requestMessage": "please approve",
160+
"status": "Approved",
161+
"provisioningState": "Succeeded"
162+
}
163+
}
164+
165+
```
166+
167+
If the "Provisioning State" (`properties.provisioningState`) of the resource is `Succeeded` and "Connection State" (`properties.status`) is `Approved`, it means that the shared private link resource is functional and Azure Web PubSub Service can communicate over the private endpoint.
168+
169+
-----
170+
171+
At this point, the private endpoint between Azure Web PubSub Service and Azure Key Vault is established.
172+
173+
Now you can configure features like custom domain as usual. **You don't have to use a special domain for Key Vault**. DNS resolution is automatically handled by Azure Web PubSub Service.
174+
175+
## Next steps
176+
177+
Learn more:
178+
179+
+ [What are private endpoints?](../private-link/private-endpoint-overview.md)
180+
+ [Configure custom domain](howto-custom-domain.md)
Loading
Loading
Loading
Loading
Loading
Loading
Loading

articles/azure-web-pubsub/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@
9090
href: howto-secure-network-access-control.md
9191
- name: Secure outbound traffic through shared private endpoints
9292
href: howto-secure-shared-private-endpoints.md
93+
- name: Access Key Vault in private network through Shared Private Endpoints
94+
href: howto-secure-shared-private-endpoints-key-vault.md
9395
- name: Use a managed identity
9496
href: howto-use-managed-identity.md
9597
- name: Configure Azure AD Authorization

0 commit comments

Comments
 (0)