Skip to content

Commit 358701b

Browse files
authored
Merge pull request #299970 from RoseHJM/mdb-dev-tunnels
MDB - Dev tunnels
2 parents 450de40 + ad97956 commit 358701b

17 files changed

+185
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
title: Configure Conditional Access Policies for Dev Tunnels
3+
description: Learn how to configure conditional access policies for the Dev tunnels service in Microsoft Entra ID to secure remote development environments and restrict access based on device management and IP ranges.
4+
author: RoseHJM
5+
contributors:
6+
ms.topic: how-to
7+
ms.date: 05/19/2025
8+
ms.author: rosemalcolm
9+
ms.reviewer: rosemalcolm
10+
---
11+
12+
# Configure conditional access policies for Dev tunnels
13+
14+
Microsoft Dev Box gives you an alternative connectivity method on top of Dev tunnels. You can develop remotely while coding locally or keep development going during Azure Virtual Desktop (AVD) outages or poor network performance. Many large enterprises using Dev Box have strict security and compliance policies, and their code is valuable to their business. Restricting Dev tunnels with conditional access policies is crucial for these controls.
15+
16+
Conditional access policies for the Dev tunnels service:
17+
18+
- Let Dev tunnels connect from managed devices, but deny connections from unmanaged devices.
19+
- Let Dev tunnels connect from specific IP ranges, but deny connections from other IP ranges.
20+
- Support other regular conditional access configurations.
21+
- Apply to both the Visual Studio Code application and VS Code web.
22+
23+
## Configure conditional access
24+
25+
The conditional access policies work correctly for the Dev tunnels service. Because registering the Dev tunnels service app to a tenant and making it available to the conditional access picker is unique, this article documents the steps.
26+
27+
## Register Dev tunnels service to a tenant
28+
29+
According to [Application and service principal objects in Microsoft Entra ID](/entra/identity-platform/app-objects-and-service-principals?tabs=browser), a service principal is created in each tenant where an application is used. However, this doesn't apply to the Dev tunnels service. The Dev tunnels service is a Microsoft service, and the service principal is created in the Microsoft Entra ID tenant where the Dev tunnels service is registered. The Dev tunnels service app isn't registered to your tenant by default, so you need to register it manually.
30+
31+
Therefore, we're using [Microsoft.Graph PowerShell](/powershell/module/microsoft.graph.authentication/connect-mggraph?view=graph-powershell-1.0&preserve-view=true) to register the app to a tenant.
32+
33+
1. Install PowerShell 7.x
34+
35+
1. Follow [Install the Microsoft Graph PowerShell SDK | Microsoft Learn](/powershell/microsoftgraph/installation?view=graph-powershell-1.0&preserve-view=true) to install Microsoft.Graph PowerShell.
36+
37+
1. Run the following commands:
38+
```powershell
39+
# Connect to Microsoft Graph
40+
Connect-MgGraph -TenatnId <TenantID> -Scopes "Application.ReadWrite.All"
41+
42+
# Register the Dev tunnels service app to the tenant
43+
$TunnelServiceAppId = "46da2f7e-b5ef-422a-88d4-2a7f9de6a0b2"
44+
New-MgServicePrincipal -AppId $TunnelServiceAppId
45+
```
46+
47+
1. Go to "Microsoft Entra ID" -> "Manage" -> "Enterprise applications" to verify if the Dev tunnels service is registered.
48+
49+
:::image type="content" source="media/how-to-conditional-access-dev-tunnels-service/dev-tunnels-register-service.png" alt-text="Screenshot of the Enterprise applications page in Microsoft Entra ID, showing the Dev tunnels service registration." lightbox="media/how-to-conditional-access-dev-tunnels-service/dev-tunnels-register-service.png":::
50+
51+
## Enable the Dev tunnels service for the conditional access picker
52+
53+
The Microsoft Entra IDteam is working on removing the need to onboard apps for them to appear in the app picker, with delivery expected in May. Therefore, we aren't onboarding Dev tunnel service to the conditional access picker. Instead, target the Dev tunnels service in a conditional access policy using [Custom Security Attributes](/entra/identity/conditional-access/concept-filter-for-applications).
54+
55+
1. Follow [Add or deactivate custom security attribute definitions in Microsoft Entra ID](/entra/fundamentals/custom-security-attributes-add?tabs=ms-powershell) to add the following Attribute set and New attributes.
56+
57+
:::image type="content" source="media/how-to-conditional-access-dev-tunnels-service/dev-tunnels-custom-attributes.png" alt-text="Screenshot of the custom security attribute definition process in Microsoft Entra ID." lightbox="media/how-to-conditional-access-dev-tunnels-service/dev-tunnels-custom-attributes.png":::
58+
59+
:::image type="content" source="media/how-to-conditional-access-dev-tunnels-service/dev-tunnels-attribute.png" alt-text="Screenshot of the new attribute creation in Microsoft Entra ID." lightbox="media/how-to-conditional-access-dev-tunnels-service/dev-tunnels-attribute.png":::
60+
61+
1. Follow [Create a conditional access policy](/entra/identity/conditional-access/concept-filter-for-applications#create-a-conditional-access-policy) to create a conditional access policy.
62+
63+
:::image type="content" source="media/how-to-conditional-access-dev-tunnels-service/dev-tunnels-conditional-access-policy.png" alt-text="Screenshot of the conditional access policy creation process for Dev tunnels service." lightbox="media/how-to-conditional-access-dev-tunnels-service/dev-tunnels-conditional-access-policy.png":::
64+
65+
1. Follow [Configure custom attributes](/entra/identity/conditional-access/concept-filter-for-applications#configure-custom-attributes) to configure the custom attribute for the Dev tunnels service.
66+
67+
:::image type="content" source="media/how-to-conditional-access-dev-tunnels-service/dev-tunnels-security-attributes.png" alt-text="Screenshot of configuring custom attributes for the Dev tunnels service in Microsoft Entra ID." lightbox="media/how-to-conditional-access-dev-tunnels-service/dev-tunnels-security-attributes.png":::
68+
69+
## Testing
70+
71+
1. Turn off the BlockDevTunnelCA
72+
73+
1. Create a DevBox in the test tenant and run the following commands inside it. Dev tunnels can be created and connected externally.
74+
```
75+
code tunnel user login --provider microsoft
76+
code tunnel
77+
```
78+
79+
1. Enable the BlockDevTunnelCA.
80+
81+
1. New connections to the existing Dev tunnels can't be established. Test with an alternate browser if a connection has already been established.
82+
83+
1. Any new attempts to execute the commands in step #2 will fail. Both errors are:
84+
85+
:::image type="content" source="media/how-to-conditional-access-dev-tunnels-service/dev-tunnels-no-access.png" alt-text="Screenshot of error message when Dev tunnels connection is blocked by conditional access policy." lightbox="media/how-to-conditional-access-dev-tunnels-service/dev-tunnels-no-access.png":::
86+
87+
1. The Microsoft Entra ID sign-in logs show these entries.
88+
89+
:::image type="content" source="media/how-to-conditional-access-dev-tunnels-service/dev-tunnels-activity-logs.png" alt-text="Screenshot of Microsoft Entra ID sign-in logs showing entries related to Dev tunnels conditional access policy." lightbox="media/how-to-conditional-access-dev-tunnels-service/dev-tunnels-activity-logs.png":::
90+
91+
## Limitations
92+
93+
With Dev Tunnels, the following limitations apply:
94+
- You can't configure conditional access policies for Dev Box service to manage Dev tunnels for Dev Box users.
95+
- You can't limit Dev tunnels that aren't managed by the Dev Box service. In the context of Dev Boxes, if the Dev tunnels GPO is configured **to allow only selected Microsoft Entra tenant IDs**, Conditional Access policies can also restrict self-created Dev tunnels.
96+
97+
## Related content
98+
- [Conditional Access policies](/entra/identity/conditional-access/concept-conditional-access-policies)
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
title: Set Up Dev Tunnels and Connect to Microsoft Dev Box Using VS Code
3+
description: Learn how to set up and connect to your Microsoft Dev Box using the Open in VS Code feature. Follow step-by-step instructions to provision a Dev Box, install the Dev Box extension, enable tunnels, and connect remotely for development.
4+
author: RoseHJM
5+
contributors:
6+
ms.topic: how-to
7+
ms.date: 05/19/2025
8+
ms.author: rosemalcolm
9+
ms.reviewer: rosemalcolm
10+
---
11+
12+
# Set up Dev tunnels in VS Code
13+
14+
Use Microsoft Dev Box with Visual Studio Code (VS Code) to create secure, cloud-based development environments. This article explains how to set up dev tunnels and connect to your Dev Box from VS Code. You'll learn how to install the required extension, enable secure tunnels, and connect remotely for a streamlined development experience. Follow these steps to get started quickly and work efficiently from anywhere.
15+
16+
## Prerequisites
17+
- A dev box.
18+
- If you don't have a dev box, create one following these steps: [Quickstart: Create and connect to a dev box by using the Microsoft Dev Box developer portal](quickstart-create-dev-box.md)
19+
20+
## Configure a dev tunnel
21+
22+
Follow these steps to set up a dev tunnel and connect to your dev box using VS Code.
23+
24+
1. Install VS Code extension
25+
26+
Search for **Dev Box** in the VS Code Extension Marketplace and install the latest version (2.0.0 as of May 15, 2025) in your **local** VS Code—not in the Dev Box you want to connect to.
27+
28+
:::image type="content" source="media/how-to-set-up-dev-tunnels/dev-tunnels-dev-box-extension.png" alt-text="Screenshot of the Dev Box extension in VS Code.":::
29+
30+
1. Sign in to Dev Box extension
31+
32+
Select the Dev Box icon in the left sidebar, and select **Sign In**.
33+
34+
:::image type="content" source="media/how-to-set-up-dev-tunnels/dev-tunnels-sign-in-extension.png" alt-text="Screenshot of the Dev Box extension showing the sign-in option.":::
35+
36+
1. Create and enable Dev Box Tunnel
37+
38+
After signing in, you'll see all the projects you can access. Choose the project where you created the Dev Box, and select the Dev Box you want to connect to.
39+
40+
If you see **No Tunnel** in the description, manually create a tunnel resource first.
41+
42+
:::image type="content" source="media/how-to-set-up-dev-tunnels/dev-tunnels-create-tunnel.png" alt-text="Screenshot of the Dev Box extension showing the option to create a tunnel.":::
43+
44+
Before enabling the tunnel, you **MUST** log into the Dev Box at least once using any client (for example, browser, Windows App, Remote Desktop client). This step is **mandatory** after each shutdown and restart to establish the required user session for setting up the tunnel. Once logged in, you can disconnect from the Dev Box.
45+
46+
You don't need to sign in every time you enable or connect to the tunnel—only after a shutdown or restart.
47+
48+
:::image type="content" source="media/how-to-set-up-dev-tunnels/dev-tunnels-enable-tunnel.png" alt-text="Screenshot of enabling the tunnel in the Dev Box extension.":::
49+
50+
Then, enable the tunnel. This process can take 1–3 minutes, as it installs VS Code on the Dev Box (if not already installed) and sets up the tunnel.
51+
52+
1. Connect to the Dev Box in VS Code
53+
54+
Once everything is set up, you can open the Dev Box in VS Code by clicking the **Connect to Tunnel** button.
55+
56+
:::image type="content" source="media/how-to-set-up-dev-tunnels/dev-tunnels-connect-tunnnel.png" alt-text="Screenshot of the Dev Box extension showing the option to connect to the tunnel.":::
57+
58+
1. Explore the remote experience in VS Code
59+
60+
Open any folder or workspace on the remote Dev Box using **File > Open File/Folder/Workspace** just as you would locally.
61+
62+
If you have a Windows Subsystem for Linux (WSL) environment on the Dev Box, connect to it using **Remote Explorer**.
63+
64+
:::image type="content" source="media/how-to-set-up-dev-tunnels/dev-tunnels-wsl-targets.png" alt-text="Screenshot of the Remote Explorer in VS Code showing WSL targets.":::
65+
66+
Select WSL targets from the dropdown to see all the WSL distributions. Open any WSL distribution in the current or a new window.
67+
68+
:::image type="content" source="media/how-to-set-up-dev-tunnels/dev-tunnels-ubuntu.png" alt-text="Screenshot of a WSL distribution terminal in VS Code.":::
69+
70+
For more information on the WSL development experience, see [Remote - WSL](https://code.visualstudio.com/docs/remote/wsl) and [Set up a WSL development environment](/windows/wsl/setup/environment).
71+
72+
## Frequently asked questions
73+
74+
- Why do I need to sign-in to the Dev Box before enabling the tunnel?
75+
76+
This step is required to establish a user session for setting up the tunnel. After the initial login, you can just disconnect from the Dev Box. Then you can enable or connect
77+
78+
- Why can't I connect to the Dev Box even if the tunnel is enabled?
79+
80+
Refresh the Dev Box extension explorer view with the button in the top right corner to check the latest status of the tunnel. If the tunnel is enabled, but you still can't connect, try disabling the tunnel, signing in to the Dev Box, and then re-enabling the tunnel.nnect, try disabling the tunnel, logging into the Dev Box, and then re-enabling the tunnel.
81+
82+
## Related content
83+
- [Configure Conditional Access Policies for Dev Tunnels](how-to-conditional-access-dev-tunnels-service.md)
109 KB
Loading
136 KB
Loading
332 KB
Loading
63.6 KB
Loading
21 KB
Loading
22.6 KB
Loading
234 KB
Loading
17.5 KB
Loading

0 commit comments

Comments
 (0)