Skip to content
| Marketplace
Sign in
Azure DevOps>Azure Pipelines>Azure VM Start/Stop
Azure VM Start/Stop

Azure VM Start/Stop

Aammir Mirza

|
632 installs
| (6) | Free
Help reduce Azure compute cost. Lower environment VMs can be Start/Stop/Restart via Azure pipelines.
Get it free

Azure VM Start / Stop / Restart Management (In-bulk)

Author - Aammir Mirza

Donate

Use to manage Azure VMs Start / Stop / Restart operations in bulk. For un-used VMs or Development environment VMs, AzDO pipeline can be schedule run to Shutdown/Startup of VMs based on required hours. As a best prectice in cost savings it reduces the cost for un-used compute.

Microsoft best practice (recommendation) for cost saving

Optimize virtual machine spend by resizing or shutting down underutilized instances Although certain application scenarios can result in low utilization by design, you can often save money by scheduling shutdown of your virtual machines.

The recommended actions are shut down or resize, specific to the resource being evaluated.

The advanced evaluation model in Advisor considers shutting down virtual machines when all of these statements are true:

The current load doesn’t go above 80% utilization for workloads that aren't user facing. The load doesn't go above 40% for user-facing workloads. Here, Advisor determines the type of workload by analyzing the CPU utilization characteristics of the workload.

Also, extension supports Startup of the VMs which can be schedules as the same way like Shut down

Automate schedule with Azure DevOps pipeline using AzureVMStart/Stop task. It can reduce the overhead of maintaining / modifying individual Virtual Machine schedules every now and then from Portal or AzCLI. By scheduling the AzDO pipeline with this extension we can Shutdown / Startup computes based on requirement.

Extension also provides flexibility to manage VMs based on below possible condition:

  • Run for all VMs within the listed ResourceGroup(s), using the resource group field, with exclude list of VMs option (if required) for exclusion of VMs in the RG.
  • Run for all VMs listed in VM List (applicable for single RG only)
  • If no arguments (neither ResourceGroup nor VM List) is provided, it will run for all the RGs and VMs within the scope of Service Connection with exclude list of VMs option (if required)

Sample evaluation of cost saving within a week

How much could you save shutting down Non-Production VMs ?

Days On Time Off Time % Saved
Monday – Saturday 0600 2200 43%
Monday – Saturday 0700 2100 50%
Monday – Saturday 0800 2000 57%
Monday – Friday 0600 2200 52%
Monday – Friday 0700 2100 58%
Monday – Friday 0800 2000 64%

Platform

  • Windows

Installation

Download the Free 'Azure VM Start/Stop Tasks' from here and populate the below mentioned parameters to get it working

Configuration

Classic Pipeline (UI)

Adding the extension using classic pipeline (UI-Based pipeline in AzDO)

  • Action: Select appropriate action Start/Stop/Restart, to perform on the Virtual machine(s).

  • Azure RM Subscription: Select appropriate SPN, or create one based on available subscriptions from the drop down list. Note: If VMs not provided exclusively, all the VMs unders the select scope will be operated.

  • ResourceGroupName (Advanced): In case you choose to perform operation on all the VMs within the Resource Group, provide the delimited list of RGs to perform the action.

Eg: 'RG1,RG2,RG3.....RGn' Please respect the format

  • vmsExcludedFromAction (Advanced): If you want to skip or exclude virtual machines you can provide the list of virtual machines to skip the operation.

Eg: 'VM1,VM2,VM3.....VMn' Please respect the format

  • Simulate : Check What-If, for the selected action. Run as sandbox and verbosed the action. (No operation performed on VMs)

YAML Usage

steps:
- task: AammirMirza.CP-AzureVMStartStop.AzureVMStartStop-Task.AzureVMStartStop@1
  displayName: 'Azure VM Start/Stop'
  inputs:
    ResourceGroupName: "az-appliance,NetworkWatcherRG" # Optional list of RGs to be actioned
    Action: "Start" # Available actions Start/Stop/Restart
    ConnectedServiceName: myfreeSub # Service Connection MANDATORY
    vmsExcludedFromAction: "VMx,VMy" # Optional, If want to omit list of the VMs from bulk action, those list will be skipped.
    Simulate: true # Check what would have happened

GIF for reference

Running STOP action for all the VMs in a single ResourceGroup (or multiple RGs). Using the scheduled (cron) yml pipeline.

If you cannot see GIF follow the link

Running START action on all VMs within a single ResourceGroup, excluding VM (using VM exclusion). In example used a single VM from single RG. It could be multiple VMs from multiple RGs.

If you cannot see GIF follow the link

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Limitation

  • Available for Windows based agent only

Updates

Issue fixed for incocorrectly giving ERROR at the output/console of the task completion.

License

MIT

Support

emailto: aammir.mirza@hotmail.com

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft