Skip to content

Commit c18adf9

Browse files
authored
Merge pull request #176641 from v-thepet/dtl1
Refresh two articles
2 parents f1625c0 + 2131d68 commit c18adf9

13 files changed

+142
-90
lines changed
Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
2-
title: Create a custom image from VHD file using Azure PowerShell
3-
description: Automate creation of a custom image in Azure DevTest Labs from a VHD file using PowerShell
2+
title: Create a custom image from VHD file by using Azure PowerShell
3+
description: Automate creation of a custom image in Azure DevTest Labs from a VHD file by using PowerShell.
44
ms.topic: how-to
5-
ms.date: 06/26/2020
5+
ms.date: 10/24/2021
66
ms.custom: devx-track-azurepowershell
77
---
88

9-
# Create a custom image from a VHD file using PowerShell
9+
# Create a custom image from a VHD file with PowerShell
1010

1111
[!INCLUDE [devtest-lab-create-custom-image-from-vhd-selector](../../includes/devtest-lab-create-custom-image-from-vhd-selector.md)]
1212

@@ -16,71 +16,78 @@ ms.custom: devx-track-azurepowershell
1616

1717
[!INCLUDE [updated-for-az](../../includes/updated-for-az.md)]
1818

19-
## Step-by-step instructions
19+
## PowerShell steps
2020

21-
The following steps walk you through creating a custom image from a VHD file using PowerShell:
21+
The following steps walk you through creating a custom image from a VHD file by using Azure PowerShell:
2222

23-
1. At a PowerShell prompt, log in to your Azure account with the following call to the **Connect-AzAccount** cmdlet.
23+
1. At a PowerShell command prompt, sign in to your Azure account with the **Connect-AzAccount** cmdlet:
2424

25-
```powershell
26-
Connect-AzAccount
27-
```
25+
```powershell
26+
Connect-AzAccount
27+
```
2828

29-
1. Select the desired Azure subscription by calling the **Select-AzSubscription** cmdlet. Replace the following placeholder for the **$subscriptionId** variable with a valid Azure subscription ID.
29+
1. Select your Azure subscription with the **Select-AzSubscription** cmdlet. Replace \<subscription ID> with your subscription ID GUID.
3030

31-
```powershell
32-
$subscriptionId = '<Specify your subscription ID here>'
33-
Select-AzSubscription -SubscriptionId $subscriptionId
34-
```
31+
```powershell
32+
$subscriptionId = '<subscription ID>'
33+
Select-AzSubscription -SubscriptionId $subscriptionId
34+
```
3535

36-
1. Get the lab object by calling the **Get-AzResource** cmdlet. Replace the following placeholders for the **$labRg** and **$labName** variables with the appropriate values for your environment.
36+
1. Get the lab object by calling the **Get-AzResource** cmdlet. Replace the \<lab resource group name> and \<lab name> placeholders with your own resource group and lab names.
3737

38-
```powershell
39-
$labRg = '<Specify your lab resource group name here>'
40-
$labName = '<Specify your lab name here>'
41-
$lab = Get-AzResource -ResourceId ('/subscriptions/' + $subscriptionId + '/resourceGroups/' + $labRg + '/providers/Microsoft.DevTestLab/labs/' + $labName)
42-
```
38+
```powershell
39+
$labRg = '<lab resource group name>'
40+
$labName = '<lab name>'
41+
$lab = Get-AzResource -ResourceId ('/subscriptions/' + $subscriptionId + '/resourceGroups/' + $labRg + '/providers/Microsoft.DevTestLab/labs/' + $labName)
42+
```
4343

44-
1. Replace the following placeholder for the **$vhdUri** variable with the URI to your uploaded VHD file. You can get the VHD file's URI from the storage account's blob blade in the Azure portal.
44+
1. Replace the placeholder for the **$vhdUri** variable with the URI of your uploaded VHD file. You can get the VHD file's URI from its blob page in the lab's storage account in the Azure portal. An example VHD URI is: `https://acontosolab1234.blob.core.windows.net/uploads/myvhd.vhd`.
4545

46-
```powershell
47-
$vhdUri = '<Specify the VHD URI here>'
48-
```
46+
```powershell
47+
$vhdUri = '<VHD URI>'
48+
```
4949

50-
1. Create the custom image using the **New-AzResourceGroupDeployment** cmdlet. Replace the following placeholders for the **$customImageName** and **$customImageDescription** variables to meaningful names for your environment.
50+
1. Create the custom image by using the **New-AzResourceGroupDeployment** cmdlet. Replace the \<custom image name> and \<custom image description> placeholders with the name and description you want.
5151

52-
```powershell
53-
$customImageName = '<Specify the custom image name>'
54-
$customImageDescription = '<Specify the custom image description>'
52+
```powershell
53+
$customImageName = '<custom image name>'
54+
$customImageDescription = '<custom image description>'
5555
56-
$parameters = @{existingLabName="$($lab.Name)"; existingVhdUri=$vhdUri; imageOsType='windows'; isVhdSysPrepped=$false; imageName=$customImageName; imageDescription=$customImageDescription}
56+
$parameters = @{existingLabName="$($lab.Name)"; existingVhdUri=$vhdUri; imageOsType='windows'; isVhdSysPrepped=$false; imageName=$customImageName; imageDescription=$customImageDescription}
5757
58-
New-AzResourceGroupDeployment -ResourceGroupName $lab.ResourceGroupName -Name CreateCustomImage -TemplateUri 'https://raw.githubusercontent.com/Azure/azure-devtestlab/master/samples/DevTestLabs/QuickStartTemplates/201-dtl-create-customimage-from-vhd/azuredeploy.json' -TemplateParameterObject $parameters
59-
```
58+
New-AzResourceGroupDeployment -ResourceGroupName $lab.ResourceGroupName -Name CreateCustomImage -TemplateUri 'https://raw.githubusercontent.com/Azure/azure-devtestlab/master/samples/DevTestLabs/QuickStartTemplates/201-dtl-create-customimage-from-vhd/azuredeploy.json' -TemplateParameterObject $parameters
59+
```
6060

61-
## PowerShell script to create a custom image from a VHD file
61+
## Complete PowerShell script
6262

63-
The following PowerShell script can be used to create a custom image from a VHD file. Replace the placeholders (starting and ending with angle brackets) with the appropriate values for your needs.
63+
Combining the preceding steps produces the following PowerShell script that creates a custom image from a VHD file. To use the script, replace the following placeholders with your own values:
64+
65+
- \<subscription ID>
66+
- \<lab resource group name>
67+
- \<lab name>
68+
- \<VHD URI>
69+
- \<custom image name>
70+
- \<custom image description>
6471

6572
```powershell
6673
# Log in to your Azure account.
6774
Connect-AzAccount
6875
6976
# Select the desired Azure subscription.
70-
$subscriptionId = '<Specify your subscription ID here>'
77+
$subscriptionId = '<subscription ID>'
7178
Select-AzSubscription -SubscriptionId $subscriptionId
7279
7380
# Get the lab object.
74-
$labRg = '<Specify your lab resource group name here>'
75-
$labName = '<Specify your lab name here>'
81+
$labRg = '<lab resource group name>'
82+
$labName = '<lab name>'
7683
$lab = Get-AzResource -ResourceId ('/subscriptions/' + $subscriptionId + '/resourceGroups/' + $labRg + '/providers/Microsoft.DevTestLab/labs/' + $labName)
7784
7885
# Set the URI of the VHD file.
79-
$vhdUri = '<Specify the VHD URI here>'
86+
$vhdUri = '<VHD URI>'
8087
8188
# Set the custom image name and description values.
82-
$customImageName = '<Specify the custom image name>'
83-
$customImageDescription = '<Specify the custom image description>'
89+
$customImageName = '<custom image name>'
90+
$customImageDescription = '<custom image description>'
8491
8592
# Set up the parameters object.
8693
$parameters = @{existingLabName="$($lab.Name)"; existingVhdUri=$vhdUri; imageOsType='windows'; isVhdSysPrepped=$false; imageName=$customImageName; imageDescription=$customImageDescription}
@@ -89,11 +96,7 @@ $parameters = @{existingLabName="$($lab.Name)"; existingVhdUri=$vhdUri; imageOsT
8996
New-AzResourceGroupDeployment -ResourceGroupName $lab.ResourceGroupName -Name CreateCustomImage -TemplateUri 'https://raw.githubusercontent.com/Azure/azure-devtestlab/master/samples/DevTestLabs/QuickStartTemplates/201-dtl-create-customimage-from-vhd/azuredeploy.json' -TemplateParameterObject $parameters
9097
```
9198

92-
## Related blog posts
93-
94-
- [Custom images or formulas?](./devtest-lab-faq.yml#blog-post)
95-
- [Copying Custom Images between Azure DevTest Labs](https://www.visualstudiogeeks.com/blog/DevOps/How-To-Move-CustomImages-VHD-Between-AzureDevTestLabs#copying-custom-images-between-azure-devtest-labs)
96-
9799
## Next steps
98100

99-
- [Add a VM to your lab](devtest-lab-add-vm.md)
101+
- [Compare custom images and formulas in DevTest Labs](devtest-lab-comparing-vm-base-image-types.md)
102+
- [Copying Custom Images between Azure DevTest Labs](https://www.visualstudiogeeks.com/blog/DevOps/How-To-Move-CustomImages-VHD-Between-AzureDevTestLabs#copying-custom-images-between-azure-devtest-labs)
Lines changed: 77 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,109 @@
11
---
2-
title: Enable browser connection on Azure DevTest Labs virtual machines
3-
description: DevTest Labs now integrates with Azure Bastion, as an owner of the lab you can enable accessing all lab virtual machines through a browser.
2+
title: Enable browser connection to Azure DevTest Labs virtual machines
3+
description: Integrate Azure Bastion with DevTest Labs to enable accessing lab virtual machines (VMs) through a browser.
44
ms.topic: how-to
5-
ms.date: 10/28/2021
5+
ms.date: 11/02/2021
66
---
77

8-
# Enable browser connection on Azure DevTest Labs virtual machines
8+
# Enable browser connection to DevTest Labs VMs
99

10-
DevTest Labs integrates with [Azure Bastion](../bastion/index.yml), which enables you to connect to your virtual machines through a browser. You first need to enable browser connections to lab virtual machines.
10+
Azure DevTest Labs integrates with [Azure Bastion](../bastion/index.yml) to allow connecting to lab virtual machines (VMs) through a browser. As a lab owner, you can enable browser access to all your lab VMs through Azure Bastion.
1111

12-
As an owner of a lab, you can enable accessing all lab virtual machines through a browser. You don't need another client, agent, or piece of software. Azure Bastion provides secure and seamless RDP/SSH connectivity to your virtual machines directly in the Azure portal over TLS. When you connect via Azure Bastion, your virtual machines don't need a public IP address. For more information, see [What is Azure Bastion?](../bastion/bastion-overview.md)
12+
Azure Bastion provides secure and seamless remote desktop protocol (RDP) and secure shell (SSH) connectivity over transport layer security (TLS), directly from the Azure portal. You don't need any other client, agent, or software to connect to your lab VMs through your browser. Your VMs don't need public IP addresses.
1313

14-
In this guide, you'll enable browser connections to lab virtual machines.
14+
This article covers two different ways to enable Azure Bastion browser connectivity to DevTest Labs VMs:
15+
16+
- You can create a new Azure Bastion-enabled virtual network for your lab and its VMs.
17+
- You can deploy Azure Bastion in your existing lab virtual network.
1518

1619
## Prerequisites
1720

18-
- A lab in [Azure DevTest Labs](./devtest-lab-overview.md).
21+
- Have or [create a lab](tutorial-create-custom-lab.md#create-a-lab) in DevTest Labs.
22+
- To use Azure Bastion browser access, lab users must have **Reader** role on the Azure Bastion host and on the lab virtual network that has Azure Bastion configured.
23+
24+
## Option 1: Connect a lab to an Azure Bastion-enabled virtual network
25+
26+
First, create a new virtual network with an Azure Bastion subnet and another subnet in it. An Azure Bastion subnet doesn't allow creating non-Azure Bastion resources in it, so you need the other subnet for creating lab VMs.
27+
28+
1. In the Azure portal, search for and select **virtual networks**.
29+
1. Select **+ Create** at the top of the **Virtual networks** page.
30+
1. On the **Create virtual network** screen, enter a **Name** for the new virtual network, and select the same **Subscription**, **Resource group**, and **Region** as your lab.
31+
1. Select **Next: IP Addresses**.
32+
1. On the **IP Addresses** tab, there's already one subnet, **default**. Select **Add subnet**.
33+
1. On the **Add subnet** pane, enter *AzureBastionSubnet* under **Name**.
34+
1. Under **Subnet address range**, enter an address range that's within the virtual network's address space but doesn't overlap with the default subnet. If necessary, you can add new address spaces in the blank fields on the **Create virtual network** page.
35+
1. Select **Add**.
36+
37+
![Screenshot that shows creating the AzureBastionSubnet subnet.](media/enable-browser-connection-lab-virtual-machines/create-subnet.png)
1938

20-
- Your lab's virtual network configured with Bastion. See [Create an Azure Bastion host](../bastion/tutorial-create-host-portal.md) for steps on adding Bastion.
39+
1. Select **Review + create**, and when validation passes, select **Create**.
40+
1. Once the new virtual network is created, go to its page, select **Subnets** in the left navigation, and confirm that there are two subnets, **default** and **AzureBastionSubnet**.
2141

22-
- The lab user needs to be a member of the **Reader** role on the Bastion host and the virtual network that has Bastion configured.
42+
![Screenshot that shows two subnets in the Azure Bastion virtual network.](media/enable-browser-connection-lab-virtual-machines/second-subnet.png)
2343

24-
## Add virtual network to lab
44+
Next, connect your lab to the new virtual network:
2545

26-
1. Sign in to the [Azure portal](https://portal.azure.com).
46+
1. From your lab **Overview** page, select **Configuration and policies** in the left navigation.
47+
1. On the **Configuration and policies** page, select **Virtual networks** under **External resources** in the left navigation.
48+
1. On the **Configuration and policies | Virtual networks** page, select **Add** at the top.
49+
1. On the **Virtual network** page, select **Select virtual network**.
50+
1. On the **Choose virtual network** page, select the Azure Bastion-enabled virtual network you just created.
51+
1. Select **Save** at the top of the **Virtual network** page.
52+
1. On the **Configuration and policies | Virtual networks** page, remove any previous virtual network from the lab. Select **...** next to that virtual network, select **Delete**, and then select **Yes**.
2753

28-
1. Navigate to your lab in **DevTest Labs**.
54+
![Screenshot that shows deleting the old lab virtual network.](media/enable-browser-connection-lab-virtual-machines/add-virtual-network.png)
2955

30-
1. Under **Settings**, select **Configuration and policies**.
56+
Enable VM creation in the non-Azure Bastion subnet:
3157

32-
:::image type="content" source="./media/enable-browser-connection-lab-virtual-machines/portal-lab-configurations-policies.png" alt-text="Screenshot of configurations and policies.":::
58+
1. On the **Configuration and policies | Virtual networks** page, select the Azure Bastion-enabled virtual network.
59+
1. On the **Virtual network** page, make sure that both the **AzureBastionSubnet** subnet and the **default** subnet appear. If you don't see both subnets, close and reopen the page.
60+
1. Select the **default** subnet.
61+
1. On the **Lab Subnet** screen, under **Use in virtual machine creation**, select **Yes**, and then select **Save**. You can now create VMs in the default subnet of your lab virtual network.
3362

34-
1. On the **Configuration and policies** page, under **External resources**, select **Virtual networks**.
63+
![Screenshot that shows enabling V M creation in the default subnet.](./media/enable-browser-connection-lab-virtual-machines/enable-vm-creation-subnet.png)
3564

36-
1. Select your Bastion configured virtual network.
65+
## Option 2: Deploy Azure Bastion in a lab's existing virtual network
3766

38-
:::image type="content" source="./media/enable-browser-connection-lab-virtual-machines/virtual-network-added.png" alt-text="Screenshot of added virtual network.":::
67+
First, create a new Azure Bastion subnet in your lab's existing virtual network:
3968

40-
1. On the **Virtual network** page, select the subnet for VMs, not **AzureBastionSubnet**.
69+
1. In the Azure portal, search for and select **Virtual networks**.
70+
1. Select your lab's existing virtual network from the list on the **Virtual networks** page.
71+
1. On the virtual network page, select **Subnets** in the left navigation,
72+
1. On the **Subnets** page, select **+ Subnet** on the top menu.
73+
1. On the **Add Subnet screen**, enter *AzureBastionSubnet* under **Name**.
74+
1. Under **Subnet address range**, enter an address range that's within the virtual network's address space, but doesn't overlap with the existing lab subnet.
75+
>[!TIP]
76+
>You might have to cancel out of this dialog, select **Address space** in the virtual network's left navigation, and create a new address space for the subnet.
77+
1. Select **Save**.
4178

42-
1. On the **Lab Subnet** section, for the **Use in virtual machine creation** option, select **Yes**. Then select **Save**.
79+
![Screenshot that shows adding a subnet in the existing virtual network.](./media/enable-browser-connection-lab-virtual-machines/add-subnet.png)
4380

44-
:::image type="content" source="./media/enable-browser-connection-lab-virtual-machines/allow-subnet-use.png" alt-text="Screenshot of selection for allow subnet use option.":::
81+
Next, deploy the Azure Bastion host in the new Azure Bastion subnet:
4582

46-
1. On the **Virtual network** page, select **Save**. You'll then be returned to the **Virtual networks** section of **Configuration and policies**.
83+
1. In the Azure portal, search for and select **Bastions**.
84+
1. On the **Bastions** page, select **+ Create** at the top.
85+
1. On the **Create a Bastion** page, enter a **Name**, and select the same **Subscription**, **Resource group**, and **Region** as your lab.
86+
1. Under **Virtual networks**, select your lab's virtual network from the dropdown list, and make sure **AzureBastionSubnet** is selected under **Subnet**.
87+
1. Select **Review + create**, and when validation passes, select **Create**.
4788

48-
## Enable browser connection
89+
![Screenshot that shows deploying Azure Bastion in the existing virtual network.](./media/enable-browser-connection-lab-virtual-machines/create-bastion.png)
4990

50-
Once you have a Bastion configured virtual network inside the lab, as a lab owner, you can enable browser connect to lab virtual machines.
91+
## Connect to lab VMs through Azure Bastion
5192

52-
These steps continue immediately from the prior section.
93+
Once you deploy Azure Bastion in your lab virtual network, enable browser connections for the lab:
5394

54-
1. Under **Settings**, select **Browser connect**.
95+
1. On the lab **Overview** page, select **Configuration and policies**, and then select **Browser connect** under **Settings**.
96+
1. On the **Browser connect** page, select **On**.
97+
1. Select **Save** at the top of the page.
5598

56-
1. Under the **Browser access to virtual machines** section, select **Yes** for **Browser connect**. Then select **Save**.
99+
![Screenshot that shows enabling the browser connection.](./media/enable-browser-connection-lab-virtual-machines/browser-connect.png)
57100

58-
:::image type="content" source="./media/enable-browser-connection-lab-virtual-machines/enable-browser-connect.png" alt-text="Screenshot of enabling browser connect option.":::
101+
To connect to a lab VM through Azure Bastion:
59102

60-
## Next Steps
103+
1. Select a lab VM from **My virtual machines** on the lab **Overview** page.
104+
1. At the top of the VM's page, select **Browser connect**.
105+
1. In the **Browser connect** pane, enter your VM's username and password, and select **Connect**.
61106

62-
See the following article to learn how to connect to your VMs using a browser: [Connect to your virtual machines through a browser](connect-virtual-machine-through-browser.md)
107+
## Next steps
108+
- [What is Azure Bastion?](../bastion/bastion-overview.md)
109+
- [Add a VM to your lab](devtest-lab-add-vm.md)
62.3 KB
Loading
43.7 KB
Loading
58.5 KB
Loading
47.8 KB
Loading
76.7 KB
Loading
45.6 KB
Loading
43.4 KB
Loading

0 commit comments

Comments
 (0)