Automated way to Stop and Start Scaling Scripts

%3CLINGO-SUB%20id%3D%22lingo-sub-2791434%22%20slang%3D%22en-US%22%3EAutomated%20way%20to%20Stop%20and%20Start%20Scaling%20Scripts%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2791434%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20have%20scaling%20scripts%20that%20run%20for%20an%20AVD%20pool%20that%20takes%20the%2015%20VM%20pool%20down%20to%202%20running%20VMs%20during%20off-peak%20hours.%26nbsp%3B%20This%20scaling%20script%20runs%20every%2015%20minutes%20and%20will%20shut%20down%20anymore%20than%202%20running%20VMs%20if%20not%20in%20use.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20also%20have%20Azure%20Update%20Management%20setup%20for%20installing%20security%20updates%20%2F%20patches%20on%20the%20VMs%20in%20the%20Pool.%26nbsp%3B%20This%20starts%20the%20VMs%20on%20Saturday%20nights%20at%2011%20PM%20and%20goes%20through%20the%20update%20process.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAn%20issue%20we%20are%20experiencing%20is%20that%20the%20scaling%20script%20is%20shutting%20down%20VMs%20in%20the%20pool%20before%20Windows%20Updates%20can%20be%20run%20and%20installed%20on%20the%20VMs.%26nbsp%3B%20The%20VMs%20boot%20up%20at%2011%20PM%2C%20but%20most%20end%20up%20getting%20shut%20down%20within%2015-30%20minutes%20by%20scaling%20script%20and%20never%20even%20start%20the%20Windows%20Updates%20process.%26nbsp%3B%20%26nbsp%3BIf%20you%20look%20in%20the%20logs%20for%20Update%20Management%20on%20the%20VMs%2C%20there%20is%20nothing%20listed%20as%20they%20shut%20down%20before%20they%20could%20start%20the%20process.%26nbsp%3B%20The%20only%20VMs%20that%20run%20the%20process%20are%20the%20ones%20the%20script%20doesnt%20auto%20shutdown.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20can%20I%20do%20to%20allow%20these%20VMs%20to%20be%20started%20at%2011%20PM%20on%20Saturday%20nights%20and%20run%20through%20Windows%20Updates%20before%20they%20are%20shut%20down%20again%20by%20scaling%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2791434%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Virtual%20Desktop%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%20Updates%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2794414%22%20slang%3D%22en-US%22%3ERe%3A%20Automated%20way%20to%20Stop%20and%20Start%20Scaling%20Scripts%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2794414%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20use%20automation%20runbooks%20for%20this%2C%20one%20runbook%20for%20disable%20and%20one%20for%20enable.%20Use%20a%20schedule%20to%20run%20disable%20on%20the%20day%20before%20patching%20and%20then%20run%20the%20runbook%20for%20enable%20the%20day%20after.%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3ESet-AzLogicApp%20-ResourceGroupName%20%22your%20logic%20app%20resource%20group%22%20-Name%20%22logic%20app%20name%22%20-State%20%22Enabled%22%20-Force%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2795844%22%20slang%3D%22en-US%22%3ERe%3A%20Automated%20way%20to%20Stop%20and%20Start%20Scaling%20Scripts%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2795844%22%20slang%3D%22en-US%22%3EI%20like%20the%20solution%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F823248%22%20target%3D%22_blank%22%3E%40ATWVD%3C%2FA%3E%20provided.%20You%20can%20also%20use%20the%20Maintenance%20tag%20built-in%20to%20the%20AVD%20Scaling%20Automation%20solution.%20Use%20a%20runbook%20to%20tag%20the%20VM's%20and%20turn%20them%20on.%20After%20patching%2C%20remove%20the%20tag.%3C%2FLINGO-BODY%3E
Occasional Contributor

We have scaling scripts that run for an AVD pool that takes the 15 VM pool down to 2 running VMs during off-peak hours.  This scaling script runs every 15 minutes and will shut down anymore than 2 running VMs if not in use.

 

We also have Azure Update Management setup for installing security updates / patches on the VMs in the Pool.  This starts the VMs on Saturday nights at 11 PM and goes through the update process.

 

An issue we are experiencing is that the scaling script is shutting down VMs in the pool before Windows Updates can be run and installed on the VMs.  The VMs boot up at 11 PM, but most end up getting shut down within 15-30 minutes by scaling script and never even start the Windows Updates process.   If you look in the logs for Update Management on the VMs, there is nothing listed as they shut down before they could start the process.  The only VMs that run the process are the ones the script doesnt auto shutdown.

 

What can I do to allow these VMs to be started at 11 PM on Saturday nights and run through Windows Updates before they are shut down again by scaling?

 

Thank you

2 Replies

We use automation runbooks for this, one runbook for disable and one for enable. Use a schedule to run disable on the day before patching and then run the runbook for enable the day after.



Set-AzLogicApp -ResourceGroupName "your logic app resource group" -Name "logic app name" -State "Enabled" -Force

I like the solution @ATWVD provided. You can also use the Maintenance tag built-in to the AVD Scaling Automation solution. Use a runbook to tag the VM's and turn them on. After patching, remove the tag.