A key consideration when deploying Azure Virtual Desktop (AVD) infrastructure is always going to be cost management. Having a stack of VMs (Virtual Machines) unnecessarily always on makes about as much financial sense as heating a home in Melbourne in 2022. For this reason, every AVD deployment will include some measure to switch VMs off at the end of a defined working day.
In Azure land, one of the simplest ways to switch off a VM right now is to use the “Auto-Shut down” feature. It’s easily enabled, easily managed, easily understood by IT staff, includes great options to delay the shutdown, and it works well. The problem with this feature though, is it’s very much targeted at the IT department. By default, if we provide it with a notification email, we get an email that looks like the following.
Now in the context of a typical AVD end-user, telling them that their machine in “Azure DevTest Labs” is going to be shut down and providing them with the name of the actual VM (linked to the Azure Resource) and the name of the Resource Group it lives in is about as much use as a fly-screen door on a submarine.
So What Can We Do?
Thankfully, you do also have another option – you can hit a webhook and create your own process using a Logic App. Microsoft has documented this process very well here (Configure auto-shutdown policy for labs and virtual machines – Azure DevTest Labs | Microsoft Docs), which essentially guides you through replacing the default email with your own custom email.
This is great as you can now include relevant links to your own internal IT helpdesk, include your own branding, and all that nice stuff. It can still be a bit clunky though, because if we pass the default links to delay/skip shutdown and a user hits those links, a browser will open, and they will be sent to a page that looks like this
Yuck. Too techie for the assumed typical end-user of your AVD solution.
Let’s Do It Better
Rather than hitting the webhook for the Logic App and sending a custom email, let’s send an email with clickable options which will return the response to our Logic App and click that link on behalf of our users. To do this, follow the same instructions as provided in the Microsoft example, but rather than choosing the “Send Email v2” option, we will instead use “Send email with options,” using the Dynamic content from the HTTP POST we will receive from Auto Shut down. It should look something like this.
The next thing we want to do is have the Logic App hit that URL on behalf of the user. We do this with a simple HTTP GET on the URLs provided again from the Auto Shut down HTTP POST.
Finally, of course, we’ll configure the notification options in Auto-Shutdown, so our Logic App is triggered.
With all this plumbed in, we will now get a much tidier email, which looks like the following
When the user clicks the response, they stay within Outlook, and the email will be updated like so
And That’s It
Because we’re using a Logic App here, the options are vast. Perhaps using a similar method you could explore using an adaptive card posted to the user via Teams? In any case, hopefully this has given you some ideas on how to easily manage shutdowns for your users and give you a little inspiration to have a play! Ultimately you could use these Auto-Shut down POSTS for something smarter, like perhaps hitting an Azure Notification Hub with some associated push notifications being delivered to a desktop app running on the Session Host, but that might be a topic for another day.
If you are looking to start or customise your AVD deployment and want a hand, feel free to reach out.