Setting Up Virtual Lab Environments Using Azure Lab Services
Published Aug 28 2020 08:00 PM 12.7K Views

This post was written by Sagar Chandra Reddy Lankala in collaboration with Ji Eun Kwon. Sagar and Ji Eun currently serve as the Program Managers for Azure Lab Services at Microsoft.


Azure Lab Services is a managed cloud service that enables educators and IT to easily roll out cost-efficient labs with customizable virtual machines, without having to master the complexities of setting up cloud infrastructure 


Azure Lab Services helps to quickly create virtual lab environments and enables IT admins to easily run a class, set up a training lab, or host a hackathon in the cloud so that users can access lab resources from anywhere, anytime. 


Azure Lab Services provides the following key capabilities:

  • Simple User Experience  Provide immediate access to VMs for invited usersWith one click users can connect and start working - no Azure subscription needed. 
  • Flexibility – Use thousands of Azure Marketplace images or bring in your custom images to quickly provision lab VMs and use repeatedly across labs 
  • Cost Optimization and Tracking – Manage your lab budget with usage control features. Schedule designated usage times or set up recurring auto-shutdowns and start times. Track individuals’ hourly usage or limit usage by setting up quotas. 
  • Automatic Management and Scaling - Provisioning and scaling to hundreds of VMs with a single clickwith the service managing all underlying infrastructure 

Azure Lab Services has recently rolled out new cost control features that will proactively prevent waste of virtual machine usage hours inside the labs! The combination of these three automatic shutdown and disconnect features will now catch most of the cases where users accidentally leave their virtual machines running:



These settings can be configured at both the lab account level and the lab level. If the settings are enabled at the lab account level, they will be applied to all labs within the lab account. Any changes to the settings made at the lab level will override the lab account level configuration. For all new lab accounts, these settings will be turned on by default. 


Let’s look at what each setting does in detail. 


  1. Automatically disconnect users from virtual machines that the OS deems idle (Windows-only) 

This is a setting that is only available for Windows virtual machines. When the setting is turned on, any machines in the lab, including the template virtual machine, will automatically disconnect the user when the Windows OS deems the session to be idle. Windows OS’s definition of idle uses two criteria: 

  • User absence – no keyboard or mouse input 
  • Lack of resource consumption – all the processors and all the disks were idle for a certain % of time 

Users will see a message like this inside the virtual machines before they are disconnected: 

Azure II.png


Please note that the virtual machine is still running when the user is disconnected. If the user reconnects to the virtual machine by signing in, windows or files that were open or unsaved work previous to the disconnect will still be there. In this state, because the virtual machine is running, it still counts as active and accrues cost. 

To automatically shut down the idle Windows virtual machines that are disconnected, use the combination of “Disconnect users when virtual machines are idle” and “Shut down virtual machines when users disconnect” settings. 

For example, if you configure the settings as follows: 

  • Disconnect users when virtual machines are idle – 15 minutes after idle state is detected 
  • Shut down virtual machines when users disconnect” – 5 minutes after user disconnects 

The Windows virtual machines will automatically shutdown 20 minutes after the user stops using them. 

Azure III.png


  1. Automatically shut down virtual machines when users disconnect (Windows & Linux) 

This setting now supports both Windows and Linux virtual machines. When this setting is on, automatic shutdown will occur when: 

  • For Windows, Remote Desktop (RDP) connection is disconnected 
  • For Linux, SSH connection is disconnected 

This feature utilizes the Linux Diagnostic Extension and is available for only the specific distributions and versions of Linux that the Linux Diagnostic Extension supports.  

You can specify how long the virtual machines should wait for the user to reconnect before automatically shutting down. 


  1. Automatically shut down virtual machines that are started but users don’t connect 

Inside a lab, a user might start a virtual machine but never connect to it. For example: 

  • A schedule in the lab starts all virtual machines for a class session, but some students do not show up and don’t connect to their machines.  
  • A user starts a virtual machine, but forgets to connect. 

The “Shut down virtual machines when users do not connect” setting will catch these cases and automatically shut down the virtual machines.   



Please enable these settings to minimize waste in your labs and check out Azure Lab Services Blog for such important features and updates.  


1 Comment
Version history
Last update:
‎Aug 28 2020 08:06 PM
Updated by: