Giter VIP home page Giter VIP logo

azure-auto-start-stop-vms's Introduction

Azure: Auto start/stop VM

This template allows you to quickly set up an automatic schedule that starts and stops your virtual machine(s) in Azure, based solely on your own schedule and adaptation of the code. This code is based on starting and stopping the virtual machines on weekdays (Mon-Fri) and exclude the weekends (Sat-Sun).

⚠️ Before you continue reading...

Please review Pricing - Automation | Microsoft Azure because this script expects you to use Automation in Azure and is also solely developed for this purpose.

If you are looking for a different solution, please reconsider the following ones:

Azure-CLI (Bash)

The Azure CLI allows you to create and manage your Azure resources on macOS, Linux, and Windows.

⚙️ Installation

  1. Download (or copy + paste) code.ps1 to your local computer.
  2. Go to Automation Accounts - Microsoft Azure and create a new account or use an existing one.
  3. Below Process Automation, press Runbooks.
    1. Press Create a runbook.
    2. Give it a name (ie. StartStopVM-ExcludingWeekends) and select PowerShell under Runbook type.
    3. Once inside your newly created runbook, press the Edit-button on the top menu & then paste the code in there then press Save & Publish.
  4. Go to Schedules to create a new schedule. We need one to start the VM and one to stop the VM.
    1. Press Schedule and then Create a new schedule.
      1. Give it a name (ie. Start YourVirtualMachineName) and an appropriate description.
      2. Make it start from today or tomorrow and specify the time (ie. 7 AM to start) and make it recurring on every week and select Mon-Fri (to exclude weekends).
      3. Press Parameters and run settings and specify the details. (VMACTION: Start = starts the VM, Stop = stops the VM)
    2. Create a new schedule (as you did in 4.i)
      1. Give it a name (ie. Stop YourVirtualMachineName) and an appropriate description.
      2. Make it start from today or tomorrow and specify the time (ie. 8 PM to start) and make it recurring on every week and select Mon-Fri (to exclude weekends).
      3. Press Parameters and run settings and specify the details. (VMACTION: Start = starts the VM, Stop = stops the VM)

🏷️ Features

  • Automatically starts or stops all or one specific virtual machine within a resource group
  • After each start/stop, checks status of each virtual machine to ensure it is in the proper state
  • Unicode characters to visually represent all states

💡 Ideas to implement

  • Allow for more specified virtual machines to be entered in VmName to split into an array so the script can start/stop multiple machines instead of either all or one

📚 Good-to-know

A collection of good-to-know things about this script.

🔌 Starting or stopping all VMs in a resource group

To start or stop multiple virtual machines within a specified resource group, you may do the following:

  1. When scheduling in your automation account you may specify the VMNAME with an asterisk (*) in order to select all the virtual machines within the specified resource group.

azure-auto-start-stop-vms's People

Contributors

albinbatman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.