VM automatic shutdown after some idle time.
Sometimes VM's are forgotten up and they are running idle. There should be possibility to define in Auto shutdown settings that "if these VM's are idle for x hours then shut down them."
Jordan M. Nash commented
It would be great to have a check box in the Auto-shutdown Operations page to monitor the virtual machine and turn it off (deallocate) after a certain number of minutes of idle CPU activity (< 10%).
This can be achieved at a VM level using a maaged identity along with a scheduled task that runs when the VM is idle.
Senthil Gandhi commented
While they are working in the feature, here is a script you can run as a cron job from some VM to monitor and shut down idle VMs.
(needs modifications before running)
Senthil Gandhi commented
I fear for the poor product manager who has to bring up this feature from the backlog. It sure increases customer satisfaction, but will certainly impact MS bottomline.
Two years from the time the ADMIN replied and it is still not available yet? Azure can monitor resource usage to charge users. Surely that information is readily available to use for this feature. So make it happens!
Bjenk Ellefsen commented
This is definitely needed. Sometimes, an analyst will spin a VM up after the shutdown time of 5PM and do some work. If he/she forgets to shut it down, it will run all night. So, an idle time function sounds like a must and should be there as a standard practice.
We have this functionality in our current provider. It allows us to set on a VM how long the machine can stay online in minutes without any activity. Activity is defined as an RDP connection in use, amending / viewing the VM within the management portal or calling an internal API from the VM to state the machine still needs to be alive for x minutes.
This is incredibly handy for our automation and manual tests and reduces unnecessary costs.
Steve Catmull commented
I could see this being really useful in situations where we often leave dev/test environments open for extended hours (e.g, 5pm-9pm). If it has not been active for x hours before scheduled off time, shut it down early when the idle criteria is met.
As far as what constitutes idle criteria, let's light up some machine learning. Imagine if we could train it through machine-learning to identify idleness. I think it will be hard to define quantitatively but if you could start to use some of the great work in Application Insights Smart Detection that would be great.
Give us some time periods that look like idle based on performance counters / users logins, etc. Then we will help you identify false positive and false negatives. My guess would be that many machines will have unique patterns and maybe we need to opt in for idle detection. Then train on those that opt in.
Windows itself has the feature we need in the bog standard OS power management, but for whatever reason the capability isn't even presented as an option in Windows Server 2016 as deployed from the marketplace image in Azure. None of the power management options in deployed VMs even gives the "power off after X minutes" option, like every single laptop OS image has.
Giving us that option would let us configure the OS itself to decide when to shutdown based on user activity, and the OS is in the best position to decide that. Then we can script something or even have other admins manually check in the Azure Portal that a VM is "not running but still incurring charges", and then we can "stop/deprovision".
And it's probably not a long step to request an "if OS shuts down and system stays down, deprovision" feature in Azure. I bet that feature request already exists :)
I propose 2 Idle indicators:
- no user logged/interaction - for X amount of time
- CPU consumption below Y % for X amount of time
Nguyen Ngoc Tin commented
For us, if there is no interaction from user (mouse action, key press...) for 30 min then the VM should consider the developer is away and shutdown it self.
Add schedule turn on time too its useful for dev environment
Peeush Bajpai commented
For us, idle is when either there's no active user login session or when the logged in user(s) have not "used" (read: have been completely idle) the machine for some time.
Stephan Human commented
We manage this for 500 VMs, used in demo / test cases, and we need a standard way to enforce this, not just in devtest labs, but elsewhere as well.
Stephan Human commented
We are doing this today using a GPO on all our demo and training machines. It basically uses the logoff at idle policy. We then have another scheduled task that runs every 10 min, that runs and checks if there are any sessions open. If it finds zero, it will issue a shutdown with deallocate. We actually call out to an external service to do this for us. If it is not shutdown, the machine kicks in its own shutdown, but then it is not deallocated. On an hourly basis, we run another script to find any machine that is stopped, but not deallocated, and then force to to deallocated.
Karl Fasick commented
It has been helpful to me to set a CPU % less than about 5% over 15 minutes alert. Multiple people use the VM, so Yes, it's hard to nail down definition of idle, but if it gets left for too long with too many cores it starts emailing me.