Set up DevTest Labs to send auto-shutdown notification

One of popular features in Azure DevTest Labs is to automatically shut down all the lab VMs at a specified time every day. We've heard a lot of positive feedback from our customers how they like the simplicity to set up auto-shutdown for the VMs in their labs so that they can easily mitigate the cost waste from running VMs after working hours. On the other hand, we also learned that the end users (e.g. developers/testers) of the Labs could still work with the VMs when the auto-shutdown is triggered. Without any notification, these users could get kicked out of the VMs unexpectedly, without a last chance to save their work.

We are pleased to announce that DevTest Labs now supports auto-shutdown notifications. Once it's set up by the lab owner, notifications will be sent to the lab users 15 minutes before the auto-shutdown triggered if any of their VMs will be impacted. This will give lab users a chance to save their work before the shutdown. What's more, the notification also provides links for each VM for the following actions:

  • Skip the auto-shutdown for this time (through skipUrl), or,
  • Snooze the auto-shutdown for an hour or 2 hours (through delayUrl60 or delayUrl120), so that they can keep working on the VM.

Notification is sent through the Webhooks endpoints or an email address specified by lab owners in the auto-shutdown settings. In case you are not familiar with Webhooks, it allows you to build or set up integrations which subscribe to certain events. When one of those events is triggered, DevTest Labs will send a HTTP POST payload to the webhook's configured URL.

Notification at Slack

Figure 1: An auto-shutdown notification message sent to Slack by using Slack's Incoming Webhooks app

We choose Webhooks as the first thing to support for notification, because it's extensively supported by various apps (e.g. Slack, Azure Logic Apps, etc.) and allows you to implement your own way for sending notification. As an example, the remaining post will walk you through how to get auto-shutdown notification from emails by using Azure Logic Apps. Before that, let's quickly go through the basic steps to enable auto-shutdown notification in your lab.

Enable auto-shutdown notification in your lab

It is very straightforward to enable auto-shutdown notification. If you’ve already got a Webhook URL which the notification will send to, you’ll be good to go after completing the last step in this section. Otherwise, we will walk you through the steps to get a Webhook URL by creating an Azure Logic App.

Below are the steps you will follow to enable auto-shutdown notification in your lab (assuming you've already enabled auto-shutdown for your lab):

  • Go to the auto-shutdown settings of your lab.
  • For the option Send notification before auto-shutdown, select Yes.
  • Input the Webhook URL.
    The sections below will demonstrate how you get a Webhook URL from Azure Logic Apps. If you are using Slack, you can easily get the URL by installing its Incoming WebHooks app.
  • Enter an Email address. You will receive an email notification on the specified email address 15 mins before the shutdown is about to execute that will allow you to delay or skip the shutdown.
  • Click Save to save the settings.

Set up Azure Logic Apps to get email notification

Azure Logic Apps provides tons of out-of-the-box connectors that makes it super easy to integrate a service with other clients, like Office 365, twitter, etc. At the high level, the steps to set up an Logic App for email notification can be divided into four phases: create an Logic App, configure the built-in template, integrate with email client, get the Webhook URL.

Create an Azure Logic App

To get started, create a new logic app in your Azure subscription by following the steps below:

  • Click + NEW on the left-side navigation bar in Azure portal.
  • Select Web + Mobile from a list of categories in Azure Marketplace.
  • Select Logic App from the Featured Apps list.

    New Logic App

    Figure 3: Create a new Logic App

  • Input required values in Create logic app form (app name, subscription, etc.) , and click Create.

Configure the built-in template

The Logic Apps comes with a Logic Apps Designer. This is where you create an integration with your email client. Below are the steps how you set it up:

  • Open Logic Apps Designer. This is supposed to open automatically the first time when you open the app. If it's not the case, click Edit from the top of the app blade to open it.
  • Choose HTTP Request-Response template in the Logic Apps Designer. This will create 2 steps in your app: the step when an HTTP request is received, and another for response.

    Choose Logic App template

    Figure 4: Choose HTTP Request-Response template from Logic App Designer

    Default steps

    Figure 5: 2 default steps included in the template

  • In Request step, click Edit next to Using the default values for the parameters. It will expand this step with a text area for REQUEST BODY JSON SCHEMA.

    Edit request body JSON schema

    Figure 6: Edit request body JSON schema in the 1st step

  • Paste the following auto-shutdown notification schema to the REQUEST BODY JSON SCHEMA text area:
	"$schema": "",
	"properties": {
		"delayUrl120": {
			"type": "string"
		"delayUrl60": {
			"type": "string"
		"eventType": {
			"type": "string"
		"guid": {
			"type": "string"
		"labName": {
			"type": "string"
		"owner": {
			"type": "string"
		"resourceGroupName": {
			"type": "string"
		"skipUrl": {
			"type": "string"
		"subscriptionId": {
			"type": "string"
		"text": {
			"type": "string"
		"vmName": {
			"type": "string"
	"required": [
	"type": "object"
  • In Response step, leave all input fields empty except Status Code as 200.

Integrate with your email client

Now it's the time to set up integration from the response with your email client. This is the last step before it's all done!

  • Click + New step in the Logic App Designer and select Add an action to add a new step that integrates with your email client.

    Add a new step

    Figure 8: Add a new "action" step

  • In the popped-up action list, select an email client from the list that you want to integrate with, or search to see more that are not listed in the default list. E.g. in this walk through, let's choose Office 365 Outlook - Send an email.
    * Note: If your email account doesn't work with this client, try the other clients that work with your account, such as 
  • Choose an Office 365 Outlook action

    Figure 9: Choose the built-in action, "Office 365 Outlook - Send an email", from the list

  • Sign in an Office 365 account that will be served as the sender for notification.
  • Select TO field, and choose owner.
  • Select SUBJECT, and input a subject of the email notification. E.g. "Shutdown of machine vmName for Lab: labName."
  • Select BODY, and define the body content for email notification. E.g. "vmName is scheduled to shutdown in 15 minutes. Skip this shutdown by clicking: skipUrl. Delay shutdown for an hour: delayUrl60. Delay shutdown for 2 hours: delayUrl120."

    Configure the setup for Office 365 Outlook

    Figure 10: Configure the new step to send an email through Office 365 Outlook

  • Click Save from the top of Logic Apps Designer.

Get the Webhook URL

After the app is saved, a Webhooks URL will be generated in the first step. Let's get back to the step When an HTTP request is received, and copy the URL form HTTP POST TO THIS URL.

Get the Webhook URL

Figure 11: Get the Webhook URL from the Logic App

Then paste this URL in the auto-shutdown notification settings in your lab, and you are good to go! The screenshot below is an email sent from the logic app I configured as above:

Notification email from logic app

Figure 12: Auto-shutdown notification email sent from Azure Logic App


Hopefully you find this feature and the walk through useful. Please try it today and let us know what you think about it! If you have an idea for how to make it work better, submit your feedback (or vote for others) at the Azure DevTest Labs feedback forum.

Have a question? Check out answers or ask a new question at the MSDN Community forum.


Comments (27)

  1. Peter Bleeck says:

    This looks great but when trying to set up the Logic App I get an error saying the above json is invalid!!!

    If I parse it through a validator I get the following error :

    Error: Parse error on line 1:
    {“ $schema”: “http:
    Expecting ‘STRING’, ‘}’, got ‘undefined’

    Can’t see the error myself so any help would be appreciated.

    1. Peter Bleeck says:

      Sorted it, the issue is with the “” from the copied text!

      1. Dave Martz says:

        Peter – what did you do to fix this? I am getting the same thing.

        1. Shree Divya says:

          “” are to be replaced with “”

          1. Xiaoying Guo says:

            We’ve upgraded the blog with code snippet support. I’ve updated the code. Hopefully it will solve the copy & paste problem. Thanks!

  2. Hi,
    I can see that in the email received there are 3 links to delay or cancel the shutdown of the VM. What is behind these links? Are you calling a particular Azure Management API to delay or skip the shutdown?

    1. Xiaoying Guo says:

      @David, it calls DevTest Labs API.

  3. Stephen Frerotte says:

    When the webhooks are on and pushing to Slack our VMs don’t ever shut down. Do the links used to extend shutdown require authentication or is it possible link unfurling could trigger the delay?

    1. Xiaoying Guo says:

      @Stephen, it doesn’t require authentication. The link has already done the work for users.

  4. durga says:

    folleows as above getting error as ‘The template language expression ‘triggerBody()[‘labName’]’ cannot be evaluated because property ‘labName’ cannot be selected and vm name and subscripionid

  5. durga says:

    follows as above getting error as ‘The template language expression ‘triggerBody()[‘labName’]’ cannot be evaluated because property ‘labName’ cannot be selected and vm name and subscripionid

  6. durga says:

    hi team created logic app with above process while running theapp in response tab CodeInvalidTemplate

    MessageUnable to process template language expressions in action ‘Response’ inputs at line ‘1’ and column ‘1362’: ‘The template language expression ‘triggerBody()[‘resourceGroupName’]’ cannot be evaluated because property ‘resourceGroupName’ cannot be selected. Please see for usage details.’.

    getting the above error for vmname and labname resourcegroupname

    1. Xiaoying Guo says:

      @durga, thanks for reporting the issue! We need more information to understand why you run into the issue. Would you mind opening a post in our MSDN forum ( It will make the discussion much easier. Thanks!

  7. Bart says:

    I’m wondering where is the owner value coming from?

    1. Xiaoying Guo says:

      @Bart, the owner value is captured by the labs based on the account of user who created the VM.

      1. Bart says:

        Thank you, and what will the owner be for an ARM vm outside a LAB?

        1. Xiaoying Guo says:

          @Bart: we don’t have the owner information for an ARM-based VM outside of the lab yet, given it’s beyond the scope of information that Labs can collect. We will look into this and see if there’s any good solution.

      2. Bart says:

        I did a quick test with both labs and an arm vm. Indeed I see owner value in the request. But the owner value is non existent in the ARM vm request.

  8. pawan kumar das says:

    On trying to implement i am facing some error on execution in http Response step as :

    Unable to process template language expressions in action ‘Response’ inputs at line ‘1’ and column ‘1370’: ‘The template language expression ‘triggerBody()[‘skipUrl’]’ cannot be evaluated because property ‘skipUrl’ cannot be selected. Please see for usage details.’.

    please suggest me further changes if something required.

    1. Xiaoying Guo says:

      @pawan kumar das: could you please check if this forum post solves the problem you are facing? If not, could you please share more info on that post so that our on-call engineer can provide more assistant?

  9. beifeng2744 says:

    For saving costs, is there “auto-start” feature like auto-shutdown?

    1. Xiaoying Guo says:

      @beifeng2744: Yes, there’s an auto-start policy in DevTest Labs. Please see this document for more details.

  10. MrMartyMac says:


    I am trying to set this up to place a comment on a Trello card. In the setup of the Response, Headers is not in the list of Outputs. Can someone explain? I have followed this post to the letter otherwise.

    Thank you very much for this post, it is very helpful.

    1. MrMartyMac says:

      I was actually able to get past my initial problem related to the Headers by clicking into the Header field of the Response before pasting the schema into the Request. However, I am receiving this message:

      Unable to process template language expressions in action ‘Response’ inputs at line ‘1’ and column ‘1397’: ‘The template language expression ‘triggerBody()[‘vmName’]’ cannot be evaluated because property ‘vmName’ cannot be selected. Please see for usage details.’.

      After adding the schema and any of the output from the request.

      Can you explain whey I wouldn’t be getting the output values?

      1. MrMartyMac says:

        I am sorry for my posts. I now realize that the “test” fail because they are not being triggered by the actual requesting agent. Please remove my post if you like.

  11. Teemu Tikka says:

    Thanks for walk through! I’m trying to use this webhook in VM that isn’t included in DevTest Lab. That’s why logic app is failing with email sending operation. So couple questions:
    1. Is it possible to add alredy existing VM to Lab?
    2. Is it possible to change webhook to include some custom tag of VM (or similar) that can contain email address to use in notification step?

    1. Xiaoying Guo says:

      @Teemu, neither of your asks are supported today, but they are certainly great suggestion that we will consider when prioritizing our backlog. For #1, the workaround is to move the VHD to a DevTest Lab, create a custom image and recreate the VM.

Skip to main content