Task 02 - Deploy a Microsoft Dev Box (40 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 load an existing Dev Box definition based on a standard Windows Image.
If you do want to try to create a custom image instead of using a pre-built definition, review the Advanced Challenges section below. Note that this advanced challenge may take upwards of two hours to complete.
- Create a dev box definition using the latest version of the Visual Studio 2022 Pro on Windows 11 Enterprise + Microsoft 365 Apps 23H2 image. Call this definition
MPPDeveloperDefinition
. Set the compute to 8 vCPU and 32 GB of RAM and the storage to 256 GB SSD (or the smallest available value). - Create a dev box pool using your definition. Ensure that it deploys to the network connection you created in the prior task and that users should have Local Administrator rights.
- Instantiate the machine using the Microsoft developer portal.
-
Install the following software on your machine:
- Docker (https://docs.docker.com/desktop/install/windows-install/)
- Visual Studio Code (https://code.visualstudio.com/Download)
- Azure Storage Explorer (https://azure.microsoft.com/products/storage/storage-explorer/)
Learning Resources
- Quickstart: Configure Microsoft Dev Box
- Create a dev box by using the developer portal
- Configure a managed identity for a dev center
Tips
- To access the Dev Portal for logging in as a user visit: https://devportal.microsoft.com/.
- Ensure you assign the appropriate RBAC roles for the users who to access the dev portal to login to a virtual machine.
- The first time you need a virtual machine, you need to first create it. It can take a little bit to create the VM the first time.
Solution
Part 1: Expand this section to view the solution for creating a standard Dev Box definition.
-
In the Azure Portal, navigate to the Dev center you created in Task 1, and select Dev box definitions from the menu. Then, select Create dev box definition.
-
Create a new dev box definition with the following settings and select Create.
- Name: “MPPDeveloperDefinition”
- Image: Visual Studio 2022 Pro on Windows 11 Enterprise + Microsoft 365 Apps 23H2
- Image version: Latest
- Compute: 8vCPU, 32 GB RAM (or the smallest you can choose)
- Storage: 256 GB SSD (or the smallest you can choose)
Part 2: Expand this section for the solution to setup a dev box pool with your definition
-
Navigate to Manage dev box pools, and create a dev box pool
-
Configure the settings as seen below. Use your Dev Box Definition (standard or custom) you just created as well as the network connection you created in Task 1. You may also want to adjust the auto-stop time for your region and lab length.
-
Finally, for the Project, under Access control, assign yourself and any other users to be a “DevCenter Dev Box Users”
-
Log into your dev box and install the software you’ll need for the rest of the training. Install the following software.
- Docker (https://docs.docker.com/desktop/install/windows-install/)
- Visual Studio Code (https://code.visualstudio.com/Download)
- Azure Storage Explorer (https://azure.microsoft.com/products/storage/storage-explorer/)
Advanced Challenges
Companies may wish to create their own custom images for developer machines, finding the default images a bit limiting. Microsoft Dev Box can accommodate those demands as well, creating a custom virtual machine and converting it into an image definition.
- 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
- 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
- Visual Studio Code (System Installer):
- Before running sysprep, shut down the VM and take a snapshot. 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. Once you perform a sysprep you can’t start the VM back up again without using this snapshot.
- 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
- 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.
Advanced Challenges Learning Resources
- Create an Azure Compute gallery
- Create a Dev Box Definition
- Generalize a VM
- Create an image from a VM
Advanced Challenges 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.
It’s possible that Docker for Desktop causes issues following the creation of your Dev Box due to the custom image. To resolve, it may need to be uninstalled/reinstalled once your Dev Box is created.
Advanced Challenges 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 23H2 - 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
- 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
- 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
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 this does not complete within approximately 20 minutes, you should continue with the machine you created during this task rather than the custom image.