Blog Post

Azure Infrastructure Blog
3 MIN READ

Microsoft Dev Box Creation using Terraform

singhshub's avatar
singhshub
Icon for Microsoft rankMicrosoft
Apr 29, 2025

Azure Dev Box is a managed service from Microsoft Azure that provides cloud-hosted, developer-ready workstations (virtual machines) designed specifically for software development. It allows developers to quickly spin up secure, pre-configured, high-performance development environments without worrying about configuring physical devices or maintaining local dev setups.

Key Features of Azure Dev Box:

  • Organizations can set up custom images that include tools, libraries, and dependencies.
  • Ensures consistency across developer environments.
  • Developers can spin up Dev Boxes quickly without configuring physical machines.
  • Multiple boxes can be created for different projects or branches.

Common Use Cases:

  • Onboarding new developers quickly.
  • Creating isolated, sandboxed environments for different projects.
  • Ensuring consistent dev environments across teams.
  • Supporting remote development securely.

Benefits for Different Roles:

  • Platform Engineers: Can create dev box pools, manage security settings, network configurations, and organizational policies to ensure secure access to resources.
  • Development Team Leads: Assist with creating and managing the developer experience by being assigned the DevCenter Project Admin role.
  • Developers: Can self-serve one or more dev boxes on demand from the dev box pools enabled for a project, allowing them to work on multiple projects or tasks.

You can read more about Dev Box in Microsoft documentation https://learn.microsoft.com/en-us/azure/dev-box/

In this blog, we will be deploying the Dev Box and other related resources using Terraform. Below are the pre-requisites for Deploying the Dev Box.

Pre-Requisites:

  • Azure Subscription
  • Terraform installed locally or via Cloud Shell
  • Azure CLI installed (and logged in)
  • Dev Box preview access (Azure Dev Box must be enabled in your subscription)

We will use the below set of resources as part of this deployment:

  • Resource Group
  • Virtual Network and Subnet (for Dev Box connectivity)
  • Network Connection (links to the VNet)
  • Dev Center
  • Project
  • Dev Box Definition
  • Dev Box Pool

Deploy the Dev Center and other network components to the 'West Europe' location.


# This Terraform script creates a Dev Center in Azure with a virtual network, subnet, and a Dev Box pool.
#Creating a Resource Group
resource "azurerm_resource_group" "resourceGroup" {
  name     = "devBox-resources"
  location = "West Europe"
}

# Creating a Dev Center Resource
resource "azurerm_dev_center" "devCenter" {
  name                = "devCenterDC"
  resource_group_name = azurerm_resource_group.resourceGroup.name
  location            = azurerm_resource_group.resourceGroup.location

  identity {
    type = "SystemAssigned"
  }
}

# Creating a Virtual Network for Dev Center
resource "azurerm_virtual_network" "vnet" {
  name                = "devCenterVnet"
  address_space       = ["10.0.0.0/16"]
  location            = azurerm_resource_group.resourceGroup.location
  resource_group_name = azurerm_resource_group.resourceGroup.name
}

# Creating a Subnet for Dev Center
resource "azurerm_subnet" "subnet" {
  name                 = "devCenterSubnet"
  resource_group_name  = azurerm_resource_group.resourceGroup.name
  virtual_network_name = azurerm_virtual_network.vnet.name
  address_prefixes     = ["10.0.2.0/24"]
}

Create and attach Network Connection to the Dev Center and create Project and Dev Box.


# Creating Dev Center Network Connection
resource "azurerm_dev_center_network_connection" "devCenterNetworkCon" {
  name                = "devCenterNetworkCon"
  resource_group_name = azurerm_resource_group.resourceGroup.name
  location            = azurerm_resource_group.resourceGroup.location
  subnet_id           = azurerm_subnet.subnet.id
  domain_join_type    = "AzureADJoin"
}

# Attaching the Network Connection to the Dev Center
resource "azurerm_dev_center_attached_network" "devCenterAttachedNetwrork" {
  name                  = "devCenterAttachedNetwork"
  dev_center_id         = azurerm_dev_center.devCenter.id
  network_connection_id = azurerm_dev_center_network_connection.devCenterNetworkCon.id
}

# Creating a Dev Center Project
resource "azurerm_dev_center_project" "devCenterProject" {
  name                = "devCenterProject"
  resource_group_name = azurerm_resource_group.resourceGroup.name
  location            = azurerm_resource_group.resourceGroup.location
  dev_center_id       = azurerm_dev_center.devCenter.id
}

# Creating a Dev Box Definition
resource "azurerm_dev_center_dev_box_definition" "devCenterDevBoxDef" {
  name               = "devCenterDevBoxDef"
  location           = azurerm_resource_group.resourceGroup.location
  dev_center_id      = azurerm_dev_center.devCenter.id
  image_reference_id = "${azurerm_dev_center.devCenter.id}/galleries/default/images/microsoftvisualstudio_visualstudioplustools_vs-2022-ent-general-win10-m365-gen2"
  sku_name           = "general_i_8c32gb256ssd_v2"
}

# Creating a Dev Box Pool
resource "azurerm_dev_center_project_pool" "devCenterProjectPool" {
  name                                    = "devCenterProjectPool"
  location                                = azurerm_resource_group.resourceGroup.location
  dev_center_project_id                   = azurerm_dev_center_project.devCenterProject.id
  dev_box_definition_name                 = azurerm_dev_center_dev_box_definition.devCenterDevBoxDef.name
  local_administrator_enabled             = true
  dev_center_attached_network_name        = azurerm_dev_center_attached_network.devCenterAttachedNetwrork.name
  stop_on_disconnect_grace_period_minutes = 60
}

 

Azure Portal Output:

Note: In the upcoming articles we will deploy the catalogs and synchronize the catalogs to the GitHub repository.

Updated Apr 29, 2025
Version 1.0

2 Comments

  • mark_stable's avatar
    mark_stable
    Copper Contributor

    I get all this going excpe the final pool creation. I can do this in the portal, however Terraform gives me a:

    Pool Name: "dcet-xxxxpool-xxx-xx-xxxx-ss"): performing CreateOrUpdate: unexpected status 400 (400 Bad Request) with error: ValidationError: The request is not valid.

    I wonder if it is anything to do with the licensing tick box one gets in the portal, but cannot accept in the portal?

    • mark_stable's avatar
      mark_stable
      Copper Contributor

      It was not licensing, in dev_center_attached_network_name I was referencing the vnet and not the azurerm_dev_center_attached_network.