Showing results for 
Search instead for 
Did you mean: 

Scheduled Start / Stop of Azure VMs to reduce costs.

I think everyone has the same problem: the Azure Virtual machines runs overnight when nobody is working on it and the costs are growing.

To reduce the cost for virtual machines in Azure Microsoft Flow can be used to schedule the start/stop processes of each Virtual Machine or complete resource groups in Azure.

For this there are to setups needed to be setup: Azure Automation Account and the Flow.


Azure Automation Accounts


recurrence_start_azure_vm_10.PNGThe First steps are done in Azure.


In Azure the service "Automation Accounts" can be used for start/stop processes.


The service can easily be found by the search function in the top pane. 




In the Automation Accounts a new Account will be created by choosing "+ ADD".

It is necessary to choose the Subscription in which the virtual machines are located.

If there are virtual machines in different subscriptions for each subscription an Automation Account is needed.




In the next window the name of the Account and the used Subscription and the name of the resource group is defined.

The Location should be in the same location as the subscription is and for "create azure run as account" should be Yes.




After the account is created there the runbooks for start/stop processes has to be defined.

In the Azure Automation Account the runbooks can be found in the details.:




For this process the needed templates can be found in the gallery:




In the gallery there are the needed runbooks available:

The "Stop Azure V2 VMs" and the "Start Azure V2 VMs".

Both of them are needed as a runbook in the Automation Account.




The Following steps are similar to the Stop and the Start Runbook.


After selecting the runbook template this template has to be imported into the Automation Account.




In the next window the name of the runbook and a description is defined.




The imported runbook need to be published to be available. For this the imported runbook has to be edit:




In the edit screen the button "publish" will publish the runbook to be activated.




These steps are the setup which has to be done before setup the flows. This setup has to be done only one time because all of the future VMs in the subscription can be used with this setup.


Please be aware that described steps are an template for you but you have to check everything while doing your setup.


Microsoft Flow

After the setup in Azure is finished the setup in Microsoft Flow can be done.

For this business case you have to setup only 2 steps for stop and 2 steps for start.

These steps are 95% similiar.

Only the runbook name and the recurrence hour are different.


Here an overview of the created flow which is now described how to setup.




Now the steps to stop a machine are described.


The first step is the trigger for the recurrence so that Flow knows when to run.


To setup this step there is a connector called "Schedule" and within this connector there is a trigger called "recurrence".


In the trigger there is the setup for the time and when the flow has to run. Here in this example the trigger runs once a day at 08:36 in the time zone UTC+01:00.




There are also options available to use another frequency.

If you choose weekly at the frequency you can choose on which weekdays the flow should run.

At the bottom there is a short preview of your setup is shown.


The next step in this flow is the action to do something.

Here the action is an action from the connector called "Azure Automation".

The action to do is the "create Job" action.

This action allows flow to create automated job in azure.

This job is defined through the selected runbook.

To setup this the new Action called Azure Automation is created within the flow.




In this setup the used credentials to allow flow to connect to azure are selected and the mentioned azure subscription is selected.

Then the resource group and the account of the needed Automation Action can be selected.

The needed runbook for the stop process is selected and in the fields "VM Name" and "ResourceGroupName" the information from the virtual machine which is to processed by this flow has to entered.


The same setup but with another runbook has to be done for the start process.


Please be aware that this is only an example and you have to test it on your own risk. TEst it first on test or development environment and not on production environments.

Hope you enjoy this flow.

Find more on my blog or follow me on Twitter

About the Author
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • I am a Microsoft Business Applications MVP and a Senior Manager at EY. I am a technology enthusiast and problem solver. I work/speak/blog/Vlog on Microsoft technology, including Office 365, Power Apps, Power Automate, SharePoint, and Teams Etc. I am helping global clients on Power Platform adoption and empowering them with Power Platform possibilities, capabilities, and easiness. I am a leader of the Houston Power Platform User Group and Power Automate community superuser. I love traveling , exploring new places, and meeting people from different cultures.
  • Read more about me and my achievements at: MCT | SharePoint, Microsoft 365 and Power Platform Consultant | Contributor on SharePoint StackExchange, MSFT Techcommunity
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Founder of SKILLFUL SARDINE, a company focused on productivity and the Power Platform. You can find me on LinkedIn: and twitter I also write at, so if you want some Power Automate, SharePoint or Power Apps content I'm your guy 🙂
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 15 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Big fan of Power Platform technologies and implemented many solutions.
  • Passionate #Programmer #SharePoint #SPFx #M365 #Power Platform| Microsoft MVP | SharePoint StackOverflow, Github, PnP contributor
  • Web site – Youtube channel -