{"id":1702,"date":"2020-06-14T13:01:38","date_gmt":"2020-06-14T18:01:38","guid":{"rendered":"https:\/\/www.ciraltos.com\/?p=1702"},"modified":"2023-03-23T22:13:53","modified_gmt":"2023-03-24T03:13:53","slug":"auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function","status":"publish","type":"post","link":"https:\/\/www.ciraltos.com\/staging2\/auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function\/","title":{"rendered":"Auto Start and Stop Session Hosts in Windows Virtual Desktop Spring Update (ARM) Edition with an Azure Function"},"content":{"rendered":"\n<figure class=\"wp-block-image alignleft size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"101\" height=\"182\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/WVDFunctionApp.png\" alt=\"\" class=\"wp-image-1745\"\/><\/figure>\n\n\n\n<p>I am happy to release an update to my Windows Virtual Desktop (WVD) Start-Stop script for Windows Virtual Desktop updated for Spring 2020, or \u201cWVD ARM.\u201d&nbsp; This script uses an Azure Function to starts and stops WVD Session hosts in a host pool based on the user load.&nbsp; <\/p>\n\n\n\n<!--more-->\n\n\n\n<p>This article and script apply to the WVD ARM, or Spring Update in Public Preview as of June 2020.&nbsp; You can find information on my previous version <a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/www.ciraltos.com\/automatically-start-and-stop-wvd-vms-with-azure-automation\/\" target=\"_blank\">here<\/a>.<\/p>\n\n\n\n<p>UPDATE 1\/9\/2021 &#8211; Added the ability to change load balancing to breadth-first during peak time.  See the post <a rel=\"noreferrer noopener\" aria-label=\"here  (opens in a new tab)\" href=\"https:\/\/www.ciraltos.com\/update-with-breadth-first-auto-scale-session-hosts-in-windows-virtual-desktop-spring-update-arm-with-azure-function\/\" target=\"_blank\">here <\/a>for details.<\/p>\n\n\n\n<p>UPDATE 4\/6\/2021 &#8211; Update with steps to uncomment the az module. <\/p>\n\n\n\n<p>The GitHub page with the Function App code is located here:<br> <a href=\"https:\/\/github.com\/tsrob50\/WVD-Public\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">https:\/\/github.com\/tsrob50\/WVD-Public<\/a> <\/p>\n\n\n\n<p>An overview of deploying the script is available in this post.&nbsp; A full overview and deployment walkthrough is located here:<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"ast-oembed-container\" style=\"height: 100%;\"><iframe loading=\"lazy\" title=\"Auto Start and Stop Session Hosts in Windows Virtual Desktop Spring Update (ARM) with Azure Function\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/gdrYMPwCB9w?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe><\/div>\n<\/div><\/figure>\n\n\n\n<p>Below is a list of the changes made to the updated script:<br>PowerShell Module &#8211; Refactored to use Az.DesktopVirtualization PowerShell module instead of the Microsoft.RDInfra.PowerShell module.<br> 100% Function App \u2013 the Az.DesktopVirtualiztion module supports PowerShell Core.&nbsp; The script now runs as a PowerShell Function App.&nbsp; No more Azure Function, Azure Automation Mix.&nbsp; This includes using a System Managed Identity to start and stop the VM\u2019s.<br> Updated Start\/Stop code \u2013 Thanks to Kandice Hendricks for updating the start and stop functions in the previous version.&nbsp; Those changes are part of this script.&nbsp; The script will start and stop multiple VM\u2019s per run.&nbsp; <br> Updated Peak Time Code \u2013 I\u2019m not sure how I ever got this to work.&nbsp; The script now excepts a time zone instead of a UTC offset.&nbsp; The correct time is calculated, including DST.<\/p>\n\n\n\n<p>The following is a list of steps to deploy and modify the Function App to run the start stop script.&nbsp; A host pool should be in place prior to configuring the script (see my video on setting one up for more information).&nbsp; This script works with one host pool.&nbsp; Deploy multiple functions within the Function App to managed multiple Host Pools.<\/p>\n\n\n\n<h1>Set the Auto-Logout GPO<\/h1>\n\n\n\n<p>I start with a GPO that will log out disconnected and idle\nsessions and apply it to the Session Host OU.&nbsp;\nThis step could be skipped, but idle and disconnected sessions will\nprevent session hosts from shutting down.&nbsp;\nBe sure to set timeout values to a setting appropriate for your\nenvironment. <\/p>\n\n\n\n<p>From an account with privileges to create and manage a GPO,\ngo to Windows Administrative Tools, Group Policy Management.&nbsp; Create a new GPO and give it a name.&nbsp; Right click and Edit the GPO.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"983\" height=\"618\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/GPO-Object.png\" alt=\"\" class=\"wp-image-1705\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/GPO-Object.png 983w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/GPO-Object-300x189.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/GPO-Object-768x483.png 768w\" sizes=\"(max-width: 983px) 100vw, 983px\" \/><figcaption class=\"wp-element-caption\">GPO Object<\/figcaption><\/figure>\n\n\n\n<p>Modify the settings under Computer Configuration &gt;\nPolicies &gt; Administrative Templates &gt; Windows Components &gt; Remote\nDesktop Services &gt; Remote Desktop Session Hosts &gt; Session Time\nLimits.&nbsp; Enable and set the limit for\ndisconnected sessions and limit for active but idle RDS sessions. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"680\" height=\"631\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/Edit-Time-Limit.png\" alt=\"\" class=\"wp-image-1706\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Edit-Time-Limit.png 680w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Edit-Time-Limit-300x278.png 300w\" sizes=\"(max-width: 680px) 100vw, 680px\" \/><figcaption class=\"wp-element-caption\">Edit Time Limit<\/figcaption><\/figure>\n\n\n\n<p>Apply this GPO to the session host OU in Active directory\nonce created.<\/p>\n\n\n\n<h1>Create the Function App<\/h1>\n\n\n\n<p>This step creates a PowerShell based Function App on a\nConsumption plan.&nbsp; Modify as needed if\nyou have an app service plan in place already. <\/p>\n\n\n\n<p>Go to the Azure Portal and Create a Resource.&nbsp; Search for Function App and select Function\nApp.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"695\" height=\"466\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/Create-Function-App.png\" alt=\"\" class=\"wp-image-1707\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Create-Function-App.png 695w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Create-Function-App-300x201.png 300w\" sizes=\"(max-width: 695px) 100vw, 695px\" \/><figcaption class=\"wp-element-caption\">Create Function App<\/figcaption><\/figure>\n\n\n\n<p>Click Create at the Function App page and fill out the\ninformation in the Basics section.&nbsp; It\nshould look like below once finished.<\/p>\n\n\n\n<p>Select an existing Subscription and existing Resource Group, or create a new Resource Group.<br> Give the Function App a name.<br> Leave Publish as Code.<br> Change the Runtime Stack to PowerShell Core.&nbsp; Leave the version as 6.<br> Change the region.&nbsp; Best to select the same region as the Session Host Pool.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"760\" height=\"667\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/Function-App-Basics.png\" alt=\"\" class=\"wp-image-1708\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Function-App-Basics.png 760w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Function-App-Basics-300x263.png 300w\" sizes=\"(max-width: 760px) 100vw, 760px\" \/><figcaption class=\"wp-element-caption\">Function App Bsics<\/figcaption><\/figure>\n\n\n\n<p>Click next to Hosting.<\/p>\n\n\n\n<p>In hosting, leave the storage account to New, the Operating\nSystem to Windows.<\/p>\n\n\n\n<p>Set the Plan Type to Consumption.&nbsp; Use Premium or App Service Plan if your\nenvironment requires the added functionality.&nbsp;\nBe aware that all options have a monthly fee associated with them.&nbsp; The Consumption plan is not free but costs\nthe least.&nbsp; See the link on the\ndeployment page for more details.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"757\" height=\"604\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/Function-App-Hosting.png\" alt=\"\" class=\"wp-image-1709\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Function-App-Hosting.png 757w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Function-App-Hosting-300x239.png 300w\" sizes=\"(max-width: 757px) 100vw, 757px\" \/><figcaption class=\"wp-element-caption\">Function App Hosting<\/figcaption><\/figure>\n\n\n\n<p>Once finished, click next to Monitoring.<\/p>\n\n\n\n<p>Leave Application Insights enabled and create a new\nApplication Insights instance.&nbsp;\nAlternatively, you can select an existing if you use Application\nInsights in your environment.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"720\" height=\"370\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/Function-App-Monitoring.png\" alt=\"\" class=\"wp-image-1710\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Function-App-Monitoring.png 720w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Function-App-Monitoring-300x154.png 300w\" sizes=\"(max-width: 720px) 100vw, 720px\" \/><figcaption class=\"wp-element-caption\">Function App Monitoring<\/figcaption><\/figure>\n\n\n\n<p>Click Next to Tags.&nbsp;\nAdd Tags as needed for your environment.<\/p>\n\n\n\n<p>In Review and Create, Click Create to deploy the Function\nApp.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"369\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/Function-App-Deployment-1024x369.png\" alt=\"\" class=\"wp-image-1711\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Function-App-Deployment-1024x369.png 1024w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Function-App-Deployment-300x108.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Function-App-Deployment-768x277.png 768w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Function-App-Deployment.png 1148w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Function App Deployment<\/figcaption><\/figure>\n\n\n\n<h4>Enable the AZ Module<\/h4>\n\n\n\n<p>New function apps require the az module for the auto start and stop solution.  Go to the Function App, App Files and change the file to requirements.psd1.<\/p>\n\n\n\n<p>Remove the comment &#8220;#&#8221; from the line &#8216;Az&#8217; = &#8216;5.*&#8217; as shown below and click Save.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2021\/04\/enable-the-az-module.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"361\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2021\/04\/enable-the-az-module-1024x361.png\" alt=\"\" class=\"wp-image-2021\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2021\/04\/enable-the-az-module-1024x361.png 1024w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2021\/04\/enable-the-az-module-300x106.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2021\/04\/enable-the-az-module-768x270.png 768w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2021\/04\/enable-the-az-module.png 1272w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Enable the AZ Module<\/figcaption><\/figure>\n\n\n\n<p>Go back to the Overview page for and restart the Function App.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"446\" height=\"86\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2021\/04\/restart-function-app.png\" alt=\"\" class=\"wp-image-2022\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2021\/04\/restart-function-app.png 446w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2021\/04\/restart-function-app-300x58.png 300w\" sizes=\"(max-width: 446px) 100vw, 446px\" \/><figcaption class=\"wp-element-caption\">Restart the Function App<\/figcaption><\/figure>\n\n\n\n<h1>Create the Managed Identity<\/h1>\n\n\n\n<p>A managed Identity provides an identity that the Function\nApp will use to interact with the Session Hosts.&nbsp; A Managed Identity is a special identity with\na life cycle that matches the Function App.&nbsp;\nThe function app uses a System Managed Identity to start and stop VM\u2019s.&nbsp; When the Function App is deleted, the Managed\nIdentity is removed with it. <\/p>\n\n\n\n<p>Go to the Function App once the deployment has finished.\nClick on Identity under Settings.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"660\" height=\"484\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/Managed-Identity.png\" alt=\"\" class=\"wp-image-1713\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Managed-Identity.png 660w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Managed-Identity-300x220.png 300w\" sizes=\"(max-width: 660px) 100vw, 660px\" \/><figcaption class=\"wp-element-caption\">Managed Identity<\/figcaption><\/figure>\n\n\n\n<p>From System Assigned Managed Identity, change the status to\nOn and click Save.<\/p>\n\n\n\n<p>A verification box will appear.&nbsp; Click Yes to create the Managed Identity.&nbsp; Note the name in the box; this is the name of\nthe identity that will get RBAC rights to the Session Host Resource Group.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"882\" height=\"138\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/Enable-System-Managed-Identity.png\" alt=\"\" class=\"wp-image-1714\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Enable-System-Managed-Identity.png 882w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Enable-System-Managed-Identity-300x47.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Enable-System-Managed-Identity-768x120.png 768w\" sizes=\"(max-width: 882px) 100vw, 882px\" \/><figcaption class=\"wp-element-caption\">Enable System Managed Identity<\/figcaption><\/figure>\n\n\n\n<p>The Object ID will display once the save has finished.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"676\" height=\"465\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/Managed-Identity-Object-ID.png\" alt=\"\" class=\"wp-image-1715\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Managed-Identity-Object-ID.png 676w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Managed-Identity-Object-ID-300x206.png 300w\" sizes=\"(max-width: 676px) 100vw, 676px\" \/><figcaption class=\"wp-element-caption\">Managed Identity Object ID<\/figcaption><\/figure>\n\n\n\n<p>Next, go to the Session Host VM Resource Group.&nbsp; It is possible to deploy Session Host to a\nResource Group different from the Windows Virtual Desktop Host Pool.&nbsp; Be sure to set RBAC permissions on the VM\nResource Group.<\/p>\n\n\n\n<p>Open Access Control (IAM) from the Resource Group.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"241\" height=\"307\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/RBAC-Access-Control.png\" alt=\"\" class=\"wp-image-1716\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/RBAC-Access-Control.png 241w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/RBAC-Access-Control-236x300.png 236w\" sizes=\"(max-width: 241px) 100vw, 241px\" \/><figcaption class=\"wp-element-caption\">RBAC Access Control<\/figcaption><\/figure>\n\n\n\n<p>Click Add a Role Assignment<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"360\" height=\"202\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/Add-a-Role-Assignment.png\" alt=\"\" class=\"wp-image-1717\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Add-a-Role-Assignment.png 360w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Add-a-Role-Assignment-300x168.png 300w\" sizes=\"(max-width: 360px) 100vw, 360px\" \/><figcaption class=\"wp-element-caption\">Add a Role Assignment<\/figcaption><\/figure>\n\n\n\n<p>Set the Role as Contributor and select the Managed Identity\nsetup in the previous step.&nbsp; Click Save\nwhen finished.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"409\" height=\"486\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/Save-Role-Assignment.png\" alt=\"\" class=\"wp-image-1718\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Save-Role-Assignment.png 409w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Save-Role-Assignment-252x300.png 252w\" sizes=\"(max-width: 409px) 100vw, 409px\" \/><figcaption class=\"wp-element-caption\">Save Role Assignment<\/figcaption><\/figure>\n\n\n\n<p>Go back to the Function App, Identities, and click Azure\nRole Assignments.&nbsp; The new role shows in\nthe function app.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"716\" height=\"322\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/Azure-Role-Assignments.png\" alt=\"\" class=\"wp-image-1719\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Azure-Role-Assignments.png 716w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Azure-Role-Assignments-300x135.png 300w\" sizes=\"(max-width: 716px) 100vw, 716px\" \/><figcaption class=\"wp-element-caption\">Azure Role Assignments<\/figcaption><\/figure>\n\n\n\n<h1>Create the Function<\/h1>\n\n\n\n<p>Now that the Function App is in place and has permissions to\nthe Resource Group, we can move onto creating the Function and adding the\ncode.&nbsp; <\/p>\n\n\n\n<p>From the Function App, go to Functions.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"229\" height=\"314\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/Create-Function.png\" alt=\"\" class=\"wp-image-1721\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Create-Function.png 229w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Create-Function-219x300.png 219w\" sizes=\"(max-width: 229px) 100vw, 229px\" \/><figcaption class=\"wp-element-caption\">Create Function<\/figcaption><\/figure>\n\n\n\n<p>Click Add to add a new Function.&nbsp; Select Timer Trigger.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"517\" height=\"509\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/New-Timer-Trigger.png\" alt=\"\" class=\"wp-image-1722\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/New-Timer-Trigger.png 517w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/New-Timer-Trigger-300x295.png 300w\" sizes=\"(max-width: 517px) 100vw, 517px\" \/><figcaption class=\"wp-element-caption\">New Timer Trigger<\/figcaption><\/figure>\n\n\n\n<p>Give the new Function a name and leave the schedule as\nis.&nbsp; The new timer trigger defaults to\nrun every 5 minutes.&nbsp; <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"522\" height=\"359\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/Create-Timer-Trigger-Function.png\" alt=\"\" class=\"wp-image-1723\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Create-Timer-Trigger-Function.png 522w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Create-Timer-Trigger-Function-300x206.png 300w\" sizes=\"(max-width: 522px) 100vw, 522px\" \/><figcaption class=\"wp-element-caption\">Create Timer Trigger Function<\/figcaption><\/figure>\n\n\n\n<p>The Overview page displays once created.&nbsp; Go to Code + Test to view and change the\ncode. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"264\" height=\"355\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/Code-and-Test.png\" alt=\"\" class=\"wp-image-1724\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Code-and-Test.png 264w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Code-and-Test-223x300.png 223w\" sizes=\"(max-width: 264px) 100vw, 264px\" \/><figcaption class=\"wp-element-caption\">Code and Test<\/figcaption><\/figure>\n\n\n\n<p>Delete everything below param($Timer).&nbsp; The param($Timer) line has to stay in the\ncode for the Function App to run.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"829\" height=\"321\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/Function-App-Code-Page.png\" alt=\"\" class=\"wp-image-1725\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Function-App-Code-Page.png 829w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Function-App-Code-Page-300x116.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Function-App-Code-Page-768x297.png 768w\" sizes=\"(max-width: 829px) 100vw, 829px\" \/><figcaption class=\"wp-element-caption\">Function App Code Page<\/figcaption><\/figure>\n\n\n\n<p>Next, go to the GitHub Repo and copy the script.&nbsp; The code can is located <a href=\"https:\/\/github.com\/tsrob50\/WVD-Public\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"here   (opens in a new tab)\">here  <\/a>Click the Raw option to view and copy the code without formatting.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"315\" height=\"68\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/GitHub-Raw.png\" alt=\"\" class=\"wp-image-1726\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/GitHub-Raw.png 315w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/GitHub-Raw-300x65.png 300w\" sizes=\"(max-width: 315px) 100vw, 315px\" \/><figcaption class=\"wp-element-caption\">GitHub Raw<\/figcaption><\/figure>\n\n\n\n<p>Paste the script into the Function App Code page under the\nparam($Timer) line like below. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"280\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/Paste-Code-to-Function-App-1024x280.png\" alt=\"\" class=\"wp-image-1727\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Paste-Code-to-Function-App-1024x280.png 1024w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Paste-Code-to-Function-App-300x82.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Paste-Code-to-Function-App-768x210.png 768w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Paste-Code-to-Function-App.png 1043w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Paste Code of Function App<\/figcaption><\/figure>\n\n\n\n<p>Next, go to the Variables section and make the following\nchanges:<\/p>\n\n\n\n<p>VerbosePreference \u2013 Verbose output was added for initial\ntesting.&nbsp; Set to \u201cContinue\u201d to see the\noutput in the logs or \u201cSilentlyContinue\u201d to suppress the verbose information.<\/p>\n\n\n\n<p>ServerStartThreshold \u2013 This is the spare session capacity\nthe host pool has available between runs.&nbsp;\nIf the number of available sessions is less then this amount, a server\nwill be started.&nbsp; If the number of\navailable sessions is greater than this amount, a server will be stopped.<\/p>\n\n\n\n<p>UsePeak \u2013 Peak will modify the threshold value, so more\nsessions are available during peak business hours.&nbsp; Set this to \u201cYes\u201d if using and modify the\npeak threshold, start and stop time, time zone and Peak days as shown in the\ncode.<\/p>\n\n\n\n<p>HostPoolName \u2013 The name of the host pool to monitor.<\/p>\n\n\n\n<p>HostPoolRG and SessionHostVmRg \u2013 the Host Pool Resource Group\nand the Session Host VM Resource Group.&nbsp;\nThese are typically the same but could be different.&nbsp; Find the Host Pool Resource Group in Windows\nVirtual Desktop under Host Pool<\/p>\n\n\n\n<p>Host Pool Resource Group<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"557\" height=\"83\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/Host-Pool-Resource-Group.png\" alt=\"\" class=\"wp-image-1728\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Host-Pool-Resource-Group.png 557w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Host-Pool-Resource-Group-300x45.png 300w\" sizes=\"(max-width: 557px) 100vw, 557px\" \/><figcaption class=\"wp-element-caption\">Host Pool Resource Group<\/figcaption><\/figure>\n\n\n\n<p>Session Host VM Resource Group from Virtual Machines in the\nAzure Portal.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"663\" height=\"101\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/Session-Host-VM-Resource-Group.png\" alt=\"\" class=\"wp-image-1729\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Session-Host-VM-Resource-Group.png 663w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Session-Host-VM-Resource-Group-300x46.png 300w\" sizes=\"(max-width: 663px) 100vw, 663px\" \/><figcaption class=\"wp-element-caption\">Session Host VM Resource Group<\/figcaption><\/figure>\n\n\n\n<p>Once finished, click Save at the top of the Code + Test Page<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"487\" height=\"119\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/Save-Code.png\" alt=\"\" class=\"wp-image-1730\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Save-Code.png 487w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Save-Code-300x73.png 300w\" sizes=\"(max-width: 487px) 100vw, 487px\" \/><figcaption class=\"wp-element-caption\">Save Code<\/figcaption><\/figure>\n\n\n\n<p>Test the code by running it with the Test\/Run button (shown\nabove)<\/p>\n\n\n\n<p>At the Input Output Screen, click Run at the bottom.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"830\" height=\"232\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/Run-the-Code.png\" alt=\"\" class=\"wp-image-1731\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Run-the-Code.png 830w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Run-the-Code-300x84.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Run-the-Code-768x215.png 768w\" sizes=\"(max-width: 830px) 100vw, 830px\" \/><figcaption class=\"wp-element-caption\">Run the Code<\/figcaption><\/figure>\n\n\n\n<p>The Function should show a 202 HTTP response indicating it\nwas accepted. Close the Run window once accepted.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"643\" height=\"269\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/202-Response.png\" alt=\"\" class=\"wp-image-1732\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/202-Response.png 643w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/202-Response-300x126.png 300w\" sizes=\"(max-width: 643px) 100vw, 643px\" \/><figcaption class=\"wp-element-caption\">202 Response<\/figcaption><\/figure>\n\n\n\n<p>That\u2019s it, the script is in place and running.&nbsp; Below are some tips for managing the function\napp now that it\u2019s deployed.<\/p>\n\n\n\n<h2>Disable the Function App<\/h2>\n\n\n\n<p>I like to shut my lab session hosts down when not in\nuse.&nbsp; This script will start them back up\n(that\u2019s what it\u2019s for!).&nbsp; To disable the\nscript, to go to the Functions Overview windows and click Disable.&nbsp; This will stop the schedule, but it can still\nbe run manually.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"724\" height=\"299\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/Disable-Schedule.png\" alt=\"\" class=\"wp-image-1734\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Disable-Schedule.png 724w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Disable-Schedule-300x124.png 300w\" sizes=\"(max-width: 724px) 100vw, 724px\" \/><figcaption class=\"wp-element-caption\">Disable Schedule<\/figcaption><\/figure>\n\n\n\n<h2>View the Logs<\/h2>\n\n\n\n<p>Go to Monitor in the Function.&nbsp; This shows the log of each run.&nbsp; Note that it can take up to 5 minutes for the\nlogs to show up after a job runs.&nbsp; If\nVerbose is enabled, those messages will show up here, along with information\nand error messages.&nbsp; Verbose Logging is\nenabled by changing the $verbosPreferance in the script to \u201cContinue\u201d <em>and<\/em>\nediting the host.json file. <\/p>\n\n\n\n<p>To enable Verbose Logging, go to the Function App, App Files, and select host.json.&nbsp; Add the section of code starting with \u201clogging\u201d to the host.json file. (Be sure to add the comma as pointed out in the image below).<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\"logging\": {\n    \"logLevel\": {\n      \"default\": \"Trace\"\n    }\n  }<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"511\" height=\"417\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/Logging-host.json_.png\" alt=\"\" class=\"wp-image-1735\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Logging-host.json_.png 511w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/Logging-host.json_-300x245.png 300w\" sizes=\"(max-width: 511px) 100vw, 511px\" \/><figcaption class=\"wp-element-caption\">Logging host.json<\/figcaption><\/figure>\n\n\n\n<p>Click Save to finish<\/p>\n\n\n\n<h2>Change Run Interval<\/h2>\n\n\n\n<p>The default run interval for a time trigger is 5\nminutes.&nbsp; Set the time interval with a\nCron expression in the function.json file.&nbsp;\nInformation on how to format a Cron expression is in the Functions readme.md\nfile.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"853\" height=\"461\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/readme.md-Cron.png\" alt=\"\" class=\"wp-image-1736\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/readme.md-Cron.png 853w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/readme.md-Cron-300x162.png 300w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2020\/06\/readme.md-Cron-768x415.png 768w\" sizes=\"(max-width: 853px) 100vw, 853px\" \/><figcaption class=\"wp-element-caption\">readme.md Cron<\/figcaption><\/figure>\n\n\n\n<p>To change the schedule, modify the Cron expression in the\nfunction.json file.&nbsp; <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.ciraltos.com\/wp-content\/uploads\/2020\/06\/function.json_.png\" alt=\"\" class=\"wp-image-1737\"\/><figcaption class=\"wp-element-caption\">function.json<\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>I am happy to release an update to my Windows Virtual Desktop (WVD) Start-Stop script for Windows Virtual Desktop updated for Spring 2020, or \u201cWVD ARM.\u201d&nbsp; This script uses an Azure Function to starts and stops WVD Session hosts in a host pool based on the user load.&nbsp;<\/p>\n","protected":false},"author":1,"featured_media":3827,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":""},"categories":[569,391],"tags":[608,610,611,617,751,230,748,9,581,210,614,408,602,604,399,207,616,605,603,406,752,409,206,749,606,607,11,401,412,609,181,410,411,52,394,612,753,754,613,618,615,750,222,407,405,398,400,404,392,393],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Auto Start and Stop Session Hosts in Windows Virtual Desktop Spring Update (ARM) Edition with an Azure Function - ciraltos<\/title>\n<meta name=\"description\" content=\"This script uses a Function App to start and stop WVD Session hosts in a host pool based on the number of users logged in.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.ciraltos.com\/staging2\/auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Auto Start and Stop Session Hosts in Windows Virtual Desktop Spring Update (ARM) Edition with an Azure Function - ciraltos\" \/>\n<meta property=\"og:description\" content=\"This script uses a Function App to start and stop WVD Session hosts in a host pool based on the number of users logged in.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.ciraltos.com\/staging2\/auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function\/\" \/>\n<meta property=\"og:site_name\" content=\"ciraltos\" \/>\n<meta property=\"article:published_time\" content=\"2020-06-14T18:01:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-24T03:13:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2023\/03\/WVDFunctionApp.png\" \/>\n\t<meta property=\"og:image:width\" content=\"101\" \/>\n\t<meta property=\"og:image:height\" content=\"182\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Travis Roberts\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ciraltos\" \/>\n<meta name=\"twitter:site\" content=\"@ciraltos\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Travis Roberts\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"15 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function\/\"},\"author\":{\"name\":\"Travis Roberts\",\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a\"},\"headline\":\"Auto Start and Stop Session Hosts in Windows Virtual Desktop Spring Update (ARM) Edition with an Azure Function\",\"datePublished\":\"2020-06-14T18:01:38+00:00\",\"dateModified\":\"2023-03-24T03:13:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function\/\"},\"wordCount\":1831,\"commentCount\":60,\"publisher\":{\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a\"},\"keywords\":[\"Application Assignment\",\"Application Groups\",\"Applications\",\"automatically start\",\"automatically stop\",\"Automation\",\"az.DesktopVirtualization\",\"Azure\",\"Azure AD Application\",\"Azure Automation\",\"azure function\",\"Azure Gallery\",\"Breadth\",\"Breadth First\",\"Citrix\",\"Connection Broker\",\"cost saving\",\"Depth\",\"Depth-First\",\"Desktop\",\"function app\",\"Gateway\",\"Load Balancing\",\"Managed Identity\",\"Maximum connections\",\"maximumallowedconnections\",\"Microsoft\",\"multi user\",\"persistent desktops\",\"published apps\",\"RDS\",\"RDWeb\",\"remote access\",\"remote desktop\",\"Remote Desktop Services\",\"Service Principal\",\"spring update\",\"spring update 2020\",\"start\",\"start and stop\",\"stop\",\"System Managed Identity\",\"tutorial\",\"VDI\",\"virtualize\",\"walkthrough\",\"Windows 10\",\"Windows 7\",\"Windows Virtual Desktop\",\"WVD\"],\"articleSection\":[\"Azure Functions\",\"Windows Virtual Desktop\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.ciraltos.com\/staging2\/auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function\/\",\"url\":\"https:\/\/www.ciraltos.com\/staging2\/auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function\/\",\"name\":\"Auto Start and Stop Session Hosts in Windows Virtual Desktop Spring Update (ARM) Edition with an Azure Function - ciraltos\",\"isPartOf\":{\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#website\"},\"datePublished\":\"2020-06-14T18:01:38+00:00\",\"dateModified\":\"2023-03-24T03:13:53+00:00\",\"description\":\"This script uses a Function App to start and stop WVD Session hosts in a host pool based on the number of users logged in.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.ciraltos.com\/staging2\/auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/www.ciraltos.com\/staging2\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Auto Start and Stop Session Hosts in Windows Virtual Desktop Spring Update (ARM) Edition with an Azure Function\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#website\",\"url\":\"http:\/\/www.ciraltos.com\/staging2\/\",\"name\":\"ciraltos\",\"description\":\"cloud, technology and trends\",\"publisher\":{\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.ciraltos.com\/staging2\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a\",\"name\":\"Travis Roberts\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2023\/03\/Logo-1.png\",\"contentUrl\":\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2023\/03\/Logo-1.png\",\"width\":5657,\"height\":3563,\"caption\":\"Travis Roberts\"},\"logo\":{\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/image\/\"},\"sameAs\":[\"http:\/\/www.ciraltos.com\",\"https:\/\/twitter.com\/ciraltos\"],\"url\":\"https:\/\/www.ciraltos.com\/staging2\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Auto Start and Stop Session Hosts in Windows Virtual Desktop Spring Update (ARM) Edition with an Azure Function - ciraltos","description":"This script uses a Function App to start and stop WVD Session hosts in a host pool based on the number of users logged in.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.ciraltos.com\/staging2\/auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function\/","og_locale":"en_US","og_type":"article","og_title":"Auto Start and Stop Session Hosts in Windows Virtual Desktop Spring Update (ARM) Edition with an Azure Function - ciraltos","og_description":"This script uses a Function App to start and stop WVD Session hosts in a host pool based on the number of users logged in.","og_url":"https:\/\/www.ciraltos.com\/staging2\/auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function\/","og_site_name":"ciraltos","article_published_time":"2020-06-14T18:01:38+00:00","article_modified_time":"2023-03-24T03:13:53+00:00","og_image":[{"width":101,"height":182,"url":"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2023\/03\/WVDFunctionApp.png","type":"image\/png"}],"author":"Travis Roberts","twitter_card":"summary_large_image","twitter_creator":"@ciraltos","twitter_site":"@ciraltos","twitter_misc":{"Written by":"Travis Roberts","Est. reading time":"15 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.ciraltos.com\/staging2\/auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function\/#article","isPartOf":{"@id":"https:\/\/www.ciraltos.com\/staging2\/auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function\/"},"author":{"name":"Travis Roberts","@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a"},"headline":"Auto Start and Stop Session Hosts in Windows Virtual Desktop Spring Update (ARM) Edition with an Azure Function","datePublished":"2020-06-14T18:01:38+00:00","dateModified":"2023-03-24T03:13:53+00:00","mainEntityOfPage":{"@id":"https:\/\/www.ciraltos.com\/staging2\/auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function\/"},"wordCount":1831,"commentCount":60,"publisher":{"@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a"},"keywords":["Application Assignment","Application Groups","Applications","automatically start","automatically stop","Automation","az.DesktopVirtualization","Azure","Azure AD Application","Azure Automation","azure function","Azure Gallery","Breadth","Breadth First","Citrix","Connection Broker","cost saving","Depth","Depth-First","Desktop","function app","Gateway","Load Balancing","Managed Identity","Maximum connections","maximumallowedconnections","Microsoft","multi user","persistent desktops","published apps","RDS","RDWeb","remote access","remote desktop","Remote Desktop Services","Service Principal","spring update","spring update 2020","start","start and stop","stop","System Managed Identity","tutorial","VDI","virtualize","walkthrough","Windows 10","Windows 7","Windows Virtual Desktop","WVD"],"articleSection":["Azure Functions","Windows Virtual Desktop"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.ciraltos.com\/staging2\/auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.ciraltos.com\/staging2\/auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function\/","url":"https:\/\/www.ciraltos.com\/staging2\/auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function\/","name":"Auto Start and Stop Session Hosts in Windows Virtual Desktop Spring Update (ARM) Edition with an Azure Function - ciraltos","isPartOf":{"@id":"http:\/\/www.ciraltos.com\/staging2\/#website"},"datePublished":"2020-06-14T18:01:38+00:00","dateModified":"2023-03-24T03:13:53+00:00","description":"This script uses a Function App to start and stop WVD Session hosts in a host pool based on the number of users logged in.","breadcrumb":{"@id":"https:\/\/www.ciraltos.com\/staging2\/auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.ciraltos.com\/staging2\/auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.ciraltos.com\/staging2\/auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.ciraltos.com\/staging2\/"},{"@type":"ListItem","position":2,"name":"Auto Start and Stop Session Hosts in Windows Virtual Desktop Spring Update (ARM) Edition with an Azure Function"}]},{"@type":"WebSite","@id":"http:\/\/www.ciraltos.com\/staging2\/#website","url":"http:\/\/www.ciraltos.com\/staging2\/","name":"ciraltos","description":"cloud, technology and trends","publisher":{"@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.ciraltos.com\/staging2\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a","name":"Travis Roberts","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/image\/","url":"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2023\/03\/Logo-1.png","contentUrl":"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2023\/03\/Logo-1.png","width":5657,"height":3563,"caption":"Travis Roberts"},"logo":{"@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/www.ciraltos.com","https:\/\/twitter.com\/ciraltos"],"url":"https:\/\/www.ciraltos.com\/staging2\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/posts\/1702"}],"collection":[{"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/comments?post=1702"}],"version-history":[{"count":16,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/posts\/1702\/revisions"}],"predecessor-version":[{"id":3939,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/posts\/1702\/revisions\/3939"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/media\/3827"}],"wp:attachment":[{"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/media?parent=1702"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/categories?post=1702"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/tags?post=1702"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}