Azure

Shutdown and Startup Azure VM’s based on Tags

Like many people we want to shutdown Azure VM’s when they are not being used, however with different time zones and working schedules this can vary. The obvious way is to shutdown VM’s based on Tags.

Jobs can be scheduled through the Automation Account or via a Logic App if preferred.

The script was originally created by Christopher Scott, however it was using the older commands. I’ve updated the commands and also allowed for the tag name to be set as a Runbook Parameter when executing, these can easily be changed. This script is set to use an Azure RunAs Automation Account, but this can of course be run interactively by removing this section. The script is set to use a Tag called “ShutdownCycle” you can change this to whatever you want.

Shutdown Script

Start Up Script

Hope this helps!

2 Comments on “Shutdown and Startup Azure VM’s based on Tags

  1. Hi Rich.

    Thanks for sharing it.
    I have VMs hosted in different resource groups, will these scripts works for my entire subscription or for a specific resource group?

    Thank you so much and congrats for the blog.
    Marcus

    1. Hi there!
      It’s configured to work for specific resource groups, that said, it should be possible to configure for usage against everything in a subscription.
      Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *