Azure : Script to start or shut down multiple VMs

10,985

Definitively, you should use Azure Automation to run on schedule a PowerShell Script to shutdown or start your VM in Azure. It is already well documented on Microsoft Web site.

Here are 3 links that explains step by step how to do this

Stop Azure Virtual Machine using Azure Automation Runbook https://gallery.technet.microsoft.com/scriptcenter/Stop-Azure-Virtual-Machine-0b1fea97

Shutting down a Azure VM with Azure Automation http://blogs.technet.com/b/georgewallace/archive/2014/11/05/shutting-down-a-azure-vm-with-azure-automation.aspx

Using Azure Automation to run VMs during office hours only https://blogs.endjin.com/2015/01/using-azure-automation-to-run-vms-during-office-hours-only/

Regards

Stanislas

Share:
10,985

Related videos on Youtube

Sisyphus
Author by

Sisyphus

Updated on September 18, 2022

Comments

  • Sisyphus
    Sisyphus over 1 year

    Is it possible to write and save some kind of script that launches azure powershell, then authenticate azure subscription then start/shutdown multiple VMs in one step?

    I have 5 VMs that I use regularly at specific unscheduled time, so I don't want do the steps of logging into azure portal, starting VMs one by one then do the same to shut them down, at every time I need to use them! I need to automate this process.

    • joeqwerty
      joeqwerty over 8 years
      Why don't you just leave them running instead of shutting them down?
    • Sisyphus
      Sisyphus over 8 years
      because leaving them running means pay more money :)
    • joeqwerty
      joeqwerty over 8 years
      My bad, forgot about per hour pricing.
    • David Makogon
      David Makogon over 8 years
      @joeqwerty Not that it impacts the question, but it's per-minute pricing on VM's....