7

Is there any way in which I can automate stopping my VM on a Friday and starting this back up again on the Sunday evening at specified times?

I’m aware this is possible via the VM blade and DevTest labs but their only option is daily, whereas I want this only shut down in the weekends.

Any input will be greatly appreciated. Thanks

user9118621
  • 85
  • 1
  • 1
  • 8

2 Answers2

5

Given that you need more precise control over scheduling than is possible in the Azure VM Auto-Shutdown blade or Azure Dev-Test Labs, you can accomplish startup / shutdown on specific days via RunBooks in an Azure Automation Resource.

  1. Create (or choose an existing) Azure Automation Account resource
  2. In the new Automation resource, go to the Runbooks blade
  3. Click "Browse Gallery"
  4. Search for and import "Stop Azure V2 VMs" and "Start Azure V2 VMs" runbooks
  5. Schedule the new runbooks to run as needed

This walkthrough shows how to setup your runbooks with a specific schedule and parameters to target your virtual machine(s).

Dean Goodman
  • 973
  • 9
  • 22
  • 1
    Thanks for getting in touch. I’m aware this is possible in the VM blade & the DevTest Labs. This is what I’m doing now but the only option are the daily intervals, not the weekly occurrences. – user9118621 Dec 19 '17 at 17:18
  • In that case, you should be able to use Azure Automation to more precisely schedule. There are already 2 pre-defined RunBooks for Starting / Stopping VMs (single or in a resource group). I'll edit the answer with this solution. – Dean Goodman Dec 19 '17 at 18:15
  • Having tried the graphical interface, upon testing this it tells me it fails to close/start the VM when in fact the VM does what its meant to do. Clearly this is a programming error but Is this a known feature? It's really making me angry actually. Thanks – user9118621 Dec 21 '17 at 17:06
  • So the scripts are working (i.e. your VMs successfully startup / shutdown on the correct schedule) but the Azure UI is reporting failure? – Dean Goodman Dec 22 '17 at 16:06
  • To answer your question yes, but not so much of a failure as I think that the write-outputs are the wrong way around, so they’re the opposite to what the actual outcome was. Just a case of switching them around :) Thanks – user9118621 Dec 22 '17 at 17:15
  • Gotcha. You can edit the Runbooks after you import them - you may be able to correct the output in your local copies. – Dean Goodman Dec 22 '17 at 17:17
  • Ah I didn’t realise they were editable. That’s great, it’s a quick fix then. :) – user9118621 Dec 22 '17 at 17:18
  • Anyone have any idea on how much it will cost for an automation account? We would like to start up 10VMs monday to friday at 9AM and thats all. It charges $/per minute. So,will it charge for whole month? Or it will cost when scheduler kicks in which is hardly 10min a day. – Koushik Roy Apr 25 '20 at 18:02
  • How to shutdown VM in Azure Stack with automation account? – vish Jan 22 '21 at 09:07
4

I would recomment to you, to read this:

http://azurecorner.com/start-stop-windows-azure-vms-according-time-schedule/

Matzy
  • 353
  • 2
  • 8