A comprehensive Terraform-based infrastructure solution for provisioning Azure DevTest Labs with both Linux and Windows developer desktops. This solution enables developers to work in isolated VM environments with pre-configured artifacts and tools.
This infrastructure creates a scalable DevTest Lab environment that provides:
- Linux Developer VMs: Ubuntu-based VMs for application development and containerized workloads
- Windows Developer VMs: Windows 11 VMs for desktop application development and testing
- Artifact Management: Pre-built artifacts for common development tools and agents
- Secure Environment: Integrated Key Vault for credential management and Log Analytics for monitoring
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Azure DevTest Lab β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β βββββββββββββββββββ βββββββββββββββββββββββββββββββββββ β
β β Linux VMs β β Windows VMs β β
β β (Ubuntu 22.04) β β (Windows 11 Pro) β β
β β β β β β
β β β’ Docker β β β’ Visual Studio Code β β
β β β’ Azure Monitor β β β’ Azure Monitor Agent β β
β β β’ DevOps Agent β β β’ PowerShell β β
β βββββββββββββββββββ βββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Network Infrastructure β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β βββββββββββββββββββ βββββββββββββββββββββββββββββββββββ β
β β Virtual Network β β Azure Bastion β β
β β β β β β
β β β’ Subnets β β β’ Secure RDP/SSH Access β β
β β β’ NSG Rules β β β’ No Public IPs Required β β
β β β’ Private Links β β β’ Log Analytics Integration β β
β βββββββββββββββββββ βββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Supporting Infrastructure β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β βββββββββββββββ βββββββββββββββ βββββββββββββββββββββββ β
β β Key Vault β β Log Analyticsβ β Resource Group β β
β β β β Workspace β β β β
β β β’ VM Secretsβ β β’ Monitoring β β β’ Centralized Mgmt β β
β β β’ RBAC β β β’ Container β β β’ Tagging β β
β β β’ Encryptionβ β Insights β β β’ Lifecycle β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Azure CLI (v2.0+)
- Terraform (v1.0+)
- Azure Developer CLI (for azd workflows)
- Azure Subscription with Contributor role
# Authenticate with Azure
azd auth login
# Initialize the project
azd init
# Provision infrastructure and deploy
azd up
# Clean up resources when done
azd down# Initialize Terraform
cd infra
terraform init
# Plan the deployment
terraform plan -var-file="main.tfvars.json"
# Apply the configuration
terraform apply -var-file="main.tfvars.json"
# Destroy when done
terraform destroy -var-file="main.tfvars.json"- Purpose: Centralized management of all resources
- Naming:
rg-dtl-{environment}-{location} - Location: Configurable (default: Switzerland North)
- Purpose: Managed VM environment with cost controls and policies
- Features:
- Automatic shutdown policies
- Cost management
- Artifact repository
- Virtual network integration
- Naming:
dtl-dtl-{environment}-{location}
- OS: Ubuntu 22.04 LTS (minimal)
- Size: Standard_D4as_v5 (dev) / Standard_D8as_v5 (staging)
- Storage: Standard SSD (dev) / Premium SSD (staging)
- Features:
- Docker support
- Azure Monitor Agent
- Azure DevOps Agent capability
- OS: Windows 11 Pro (24H2)
- Size: Standard_D4as_v5 (dev) / Standard_D8as_v5 (staging)
- Storage: Standard SSD (dev) / Premium SSD (staging)
- Features:
- Visual Studio Code ready
- PowerShell 7+
- Azure Monitor Agent
- Purpose: Secure storage of VM credentials and secrets
- Features:
- RBAC authorization
- Soft delete protection
- Network access controls
- Integration with VMs for password management
- Purpose: Secure network infrastructure for DevTest Lab
- Features:
- Configurable address space and subnets
- Subnet delegation support
- Private endpoint and private link service policies
- VM protection alerts via Log Analytics
- Purpose: Secure remote access to VMs without exposing RDP/SSH ports
- Features:
- Standard SKU with static public IP
- Browser-based RDP/SSH access
- No need for public IPs on VMs
- Integrated monitoring and diagnostics
- Purpose: Network-level security controls
- Features:
- Custom security rules
- Application security group support
- Port and address prefix configurations
- Network security event logging
- Purpose: Centralized monitoring and logging
- Features:
- Container Insights solution
- VM performance monitoring
- Custom log collection
- Network security monitoring
Creates and configures the Azure DevTest Lab environment.
Key Features:
- Lab storage type configuration (Standard/Premium)
- Virtual network setup with subnet overrides
- Announcement banner configuration
- Support contact information
Variables:
lab_name: Name of the DevTest Lablab_storage_type: Storage type (Standard/Premium)announcement: Lab announcement configurationsubnet_overrides: Network configuration
Deploys virtual machines within the DevTest Lab.
Key Features:
- Automatic password generation and Key Vault storage
- Gallery image reference support
- Artifact installation capability
- Log Analytics integration
Variables:
vm_name: Virtual machine namegallery_image_reference: OS image configurationvm_size: VM size/SKUartifacts: List of artifacts to install
Manages Azure Key Vault for secure credential storage.
Key Features:
- RBAC-based access control
- Network access policies
- Soft delete and purge protection
- Integration with Log Analytics
Sets up centralized logging and monitoring.
Key Features:
- Solution installation (Container Insights)
- Configurable retention periods
- Workspace SKU management
Provides storage for artifacts and VM images (currently commented out).
Deploys Azure Bastion for secure remote access to VMs without exposing RDP/SSH ports.
Key Features:
- Standard SKU public IP with static allocation
- Integrated with Log Analytics for monitoring
- Diagnostic logging for audit and DDoS protection
- Secure access to VMs without public IPs
Variables:
name: Name of the bastion hostresource_group_name: Resource group namelocation: Azure regionsubnet_id: Subnet ID for bastion hostlog_analytics_workspace_id: Log Analytics workspace for diagnosticstags: Resource tags
Creates Azure Virtual Network with configurable subnets and network policies.
Key Features:
- Configurable address space and subnets
- Subnet delegation support
- Private endpoint and private link service policies
- Log Analytics integration for monitoring
- VM protection alerts
Variables:
name: Virtual network nameaddress_space: VNet address space (CIDR blocks)subnets: List of subnet configurationsresource_group_name: Resource group namelocation: Azure regionlog_analytics_workspace_id: Log Analytics workspace for diagnosticstags: Resource tags
Manages virtual network registration within Azure DevTest Labs.
Key Features:
- DevTest Labs-specific VNet integration
- Subnet override configurations
- Public IP address permissions
- VM creation permissions
- External provider resource integration
Variables:
name: VNet registration nameparent_id: DevTest Lab parent resource IDexternalProviderResourceId: Associated Azure VNet resource IDsubnet_overrides: Subnet configuration overridesallowed_subnets: List of allowed subnetslocation: Azure regiontags: Resource tags
Creates and configures Network Security Groups with custom security rules.
Key Features:
- Dynamic security rule creation
- Support for application security groups
- Port range and address prefix configurations
- Log Analytics integration for monitoring
- Network security event logging
Variables:
name: NSG nameresource_group_name: Resource group namelocation: Azure regionsecurity_rules: List of security ruleslog_analytics_workspace_id: Log Analytics workspace for diagnosticstags: Resource tags
-
Azure Monitor Agent (AMA)
- Installs latest Azure Monitor Agent for Linux
- Enables VM monitoring and logging
- File:
artifacts/ama-installer-linux/
-
Azure DevOps Agent
- Self-hosted agent for CI/CD pipelines
- Configurable organization, PAT, and pool settings
- File:
artifacts/linux-ado-agent-installer/
- Azure Monitor Agent (AMA)
- Silent installation of Azure Monitor Agent for Windows
- x64 architecture support
- File:
artifacts/ama-installer-windows/
The solution supports multiple environments with different configurations:
Development Environment:
- Smaller VM sizes (Standard_D4as_v5)
- Standard SSD storage
- Cost-optimized settings
Staging Environment:
- Larger VM sizes (Standard_D8as_v5)
- Premium SSD storage
- Production-like performance
# Adjust VM counts
linux_vm_count = 2
windows_vm_count = 3
# Customize VM sizes
vm_size = "Standard_D8as_v5"
# Modify storage types
storage_type = "PremiumSSD"# Lab announcement
dtl_announcement = {
enabled = "Enabled"
title = "Development Lab"
markdown = "Please shut down VMs when not in use"
}
# Storage configuration
dtl_storage_type = "Premium"The repository includes a GitHub Actions workflow (.github/workflows/azure-dev.yml) that:
- Automatically provisions infrastructure on commits to main
- Uses Azure Developer CLI for deployment
- Supports both manual and automatic triggers
- Integrates with Azure RBAC for secure deployments
- Checkout: Retrieves source code
- Install azd: Sets up Azure Developer CLI
- Authenticate: Logs into Azure using service principal
- Provision: Deploys infrastructure using Terraform
- Deploy: Configures applications and artifacts
- Automatic VM shutdown policies
- Lab-level cost controls
- Resource tagging for cost allocation
- Key Vault integration for credential management
- RBAC-based access control
- Network security groups with custom rules
- Azure Bastion for secure remote access
- Private network infrastructure
- Encrypted storage
- Log Analytics workspace integration
- Container Insights for Docker workloads
- VM performance metrics
- Network security monitoring
- Bastion host audit logs
- DDoS protection monitoring
- Custom log collection
-
VM Creation Fails
- Check Key Vault permissions
- Verify subnet configuration
- Ensure sufficient quota
-
Artifact Installation Issues
- Validate artifact JSON syntax
- Check network connectivity
- Review VM logs
-
Authentication Problems
- Verify service principal permissions
- Check Azure CLI login status
- Validate subscription access
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.