Task 02 - Setup an image (90 minutes)
Description
Typically, when a developer needs to have an environment configured for their development tasks, they need software deployed, specific versions of tools and source code, any other configurations for their development tasks. This can be a time-consuming process, particularly when onboarding a new developer or switching to a new development project.
If developers are working on multiple projects, they may even have challenges with those different projects requiring different versions of the same software. In this task, you’ll setup a Dev Box definition using a standard Windows Image. However, using Dev Box a custom image could also be created that enables software and settings to be preconfigured so as soon as a user is onboarded or needs to work on a different project, an environment can be quickly spun up for them from an image.
If you do want to try to create a custom image, look for the stretch goal solution sections within Exercise 1.
- Create a compute gallery & add it to the Dev center
-
Create a custom image using Windows 11 Enterprise, version 22H2 - x64 Gen2
Make sure you select a Windows 11 Enterprise image and not Windows 11 Pro. The Pro version is not supported for Microsoft Dev Box.
-
Include the following software on the custom image. If you have any issues selecting and copying the link you can also right click the link and select “Copy Link”.
- Visual Studio Code (System Installer):
- https://code.visualstudio.com/Download
- Make sure this finishes before installing Git so you can set it as the default editor
- Java (for JMeter):
- Apache JMeter:
- https://dlcdn.apache.org//jmeter/binaries/apache-jmeter-5.6.3.zip
- Extract the apache-jmeter-5.6.3 folder to C:\
- Azure Storage Explorer (Install for all users):
- Git bash:
- https://git-scm.com/download/win
- 64bit git for Windows Setup
- You may want to set the default editor to VSCode, keep the defaults for everything else.
- .NET SDK 8.0 LTS:
- https://dotnet.microsoft.com/download/visual-studio-sdks
- .NET 8.0 x64 Visual Studio 2022 SDK
- Firefox:
- https://www.mozilla.org/en-US/firefox/new/.
- Firefox is useful because it allows you to create a manual proxy rather than using Windows defaults, as Chrome and Edge require. This will be helpful in Exercise 4.
- Visual Studio Code (System Installer):
- Before running sysprep, shut down the VM and take a snapshot. Once you have a snapshot, boot the VM back up, login and run sysprep on the VM. Once you perform a sysprep you can’t start the VM back up again without using this snapshot.
- To perform a sysprep, do so:
- Delete C:\Windows\Panther and empty the recycle bin
- In the command prompt, CD to C:\Windows\System32\SysPrep and run
sysprep.exe /oobe /generalize /shutdown
- If the sysprep fails, make sure to read the error message, as sometimes user applications get installed (Ink being one of them), which is incompatible with sysprep.
- Create the new image
- For the VM image definition, create a new one with the name “DevBoxProject” and leave everything else as default
- VM version number can be 1.0.0
- Default storage SKU: Premium SD LRS
- Review + create –> Create
It can take anywhere from 20 minutes to an hour to create the image. If it still hasn’t completed after 15 or 20 minutes. You can start on Exercise 2 using a different machine. Task 3 of exercise 1 depends on the completely of this image creating. It is ok to use your own computer for Day 1 and use the Dev Box on day 2.
Success Criteria
- You have created a compute gallery and added it to the Dev center.
- You have created a custom image with all relevant software installed.
Learning Resources
- Create an Azure Compute gallery
- Create a Dev Box Definition
- Generalize a VM
- Create an image from a VM
Tips
- For the image creation, use the VM Size: Standard D4s v5 (4 vCPUs, 16 GiB memory) with a Windows 11 Enterprise, version 22H2 - x64 Gen2 Image
- After running sysprep on a virtual machine in Azure, you can’t use it again, so you can delete the VM along with it’s associated resources (NIC, Disk, etc.)
- For security, once you create the VM with RDP access, go into the networking settings and set the RDP access Source to be limited to your IP address
- If you do need to make changes to your VM after you ran sysprep, you’ll need to restore from the snapshot
- Create a new disk from the snapshot
- Create a new VM from the new managed disk
- Make your updates on the VM
- Create a new snapshot
- Run sysprep again.
Solution
Expand this section to view the solution to create your own custom image.
- In the Azure Portal create a new Azure Compute Gallery
- Configure the following properties. On the Sharing Tab you can keep the defaults. Create the Gallery.
- Now creating a Windows 11 Enterprise, version 22H2 - x64 Gen2 VM
- For the settings
- Basics:
- Same Resource Group you’ve been using
- Virtual Machine name: DevMPPTeamMessagingImage
- Availability options: No infrastructure redundancy required
- Security type: Trusted launch virtual machines
- Images: Windows 11 Enterprise, version 22H2 - x64 Gen2
- Note: Make sure you select enterprise and not pro. Pro is not supported for Dev Box. If you don’t see Enterprise as an option, select the link to see all images. The Select option under Microsoft Windows 11 will give you the option to select Windows 11 Enterprise, version 22H2 - x64 Gen2.
- Size: Standard_D4s_v5
- Username: DevBoxAdmin
- Password: something you’ll remember
- Licensing: Confirm
- Disks:
- Do nothing
- Networking:
- Make sure it’s connected to the network you created in the last task
- Check “Delete public IP and NIC when a VM is deleted”:
- Uncheck “Enable accelerated network”
- Management, Monitoring, Advanced
- Do nothing and take the defaults
- Create the VM
- Basics:
- Configure the network to only allow RDP access form you IP address
- Under the VM Network settings click RDP in the Network Security Group. Set Source to “My IP address” and select Save
- RDP Into the box and download/install the following software. When you install the software, if the option is available, make sure to select Install for all users:
- Visual Studio Code (System Installer):
- https://code.visualstudio.com/Download
- Make sure this finishes before installing Git so you can set it as the default editor
- Java (for JMeter):
- Apache JMeter:
- https://dlcdn.apache.org//jmeter/binaries/apache-jmeter-5.6.3.zip
- Extract the apache-jmeter-5.6.3 folder to C:\
- Azure Storage Explorer (Install for all users):
- Git bash:
- https://git-scm.com/download/win
- 64bit git for Windows Setup
- You may want to set the default editor to VSCode, keep the defaults for everything else.
- .NET SDK 8.0 LTS:
- https://dotnet.microsoft.com/download/visual-studio-sdks
- .NET 8.0 x64 Visual Studio 2022 SDK
- Firefox:
- https://www.mozilla.org/en-US/firefox/new/.
- Firefox is useful because it allows you to create a manual proxy rather than using Windows defaults, as Chrome and Edge require. This will be helpful in Exercise 4.
Before running sysprep, shut down the VM and take a snapshot. Once you have a snapshot, boot the VM back up, login and run sysprep on the VM. Once you perform a sysprep you can’t start the VM back up again without using this snapshot.
- Visual Studio Code (System Installer):
- Perform sysprep. To do so:
- Delete C:\Windows\Panther and empty the recycle bin
- In the command prompt, CD to C:\Windows\System32\SysPrep and run
sysprep.exe /oobe /generalize /shutdown
- After the Windows machine shuts down due to sysprep, navigate to your virtual machine in Azure.
- Select Capture
- Select the Azure computer gallery you created in Task 1
- Create a new Target VM image definition
- Set the Version number to 1.0.0
- Set Default storage SKU to Premium SSD LRS
- The configuration should look like this. Then create the image -Note: This step can take some time to complete. If it hasn’t completely after about 20 minute, students can proceed to Exercise 2 and use their own machines. They can check on that status periodically, and once it completes, move on to Task 3. It’s OK to use their own machine for Day 1 and use the Dev Box on day 2.