I have some Virtual Machines running in Azure that do not need to be on all the time. In fact, they are just training machines. I needed a way to stop and start the VMs out of business hours without having to do it manually. After some research I came across a Microsoft solution called Start/Stop. This solution basically creates an Automation task to stop and then start your VMs on a schedule. Below you will find a step by step guide on how to set this up.
Setup the Solution
Click on Start/Stop VMs during off-hours. Then click Create
Next, click on Workspace to either create a new OMS Workspace or use an existing.
Now click on Automation account to either create a new one or use an existing. I don’t have any so I will create a new one.
Once you have created or selected your Automation account click on Configure parameters
In here you need to fill in Target ResourceGroup Names (strin0, VM Exclude List (string),Schedule and Email notifications. Then click OK
Target ResourceGroup Names – These are resource group names that contain VMs to be managed by this solution. You can enter more than one name and separate each by using a comma (values are not case-sensitive). Using a wildcard is supported if you want to target VMs in all resource groups in the subscription. This value is stored in the External_Start_ResourceGroupNames and External_Stop_ResourceGroupNames variables.
VM Exclude List (string) – This is the name of one or more virtual machines from the target resource group. You can enter more than one name and separate each by using a comma (values are not case-sensitive). Using a wildcard is supported. This value is stored in the External_ExcludeVMNames variable.
Schedule – This is a recurring date and time for starting and stopping the VMs in the target resource groups. By default, the schedule is configured for 30 minutes from now. Selecting a different region is not available. To configure the schedule to your specific time zone after configuring the solution, see Modifying the startup and shutdown schedule.
Email notifications – Accept the default value of Yes and provide a valid email address. If you select No but decide at a later date that you want to receive email notifications, you can update the action group that is created with valid email addresses separated by a comma.
Now click Create
If you have enabled email alerts you should receive an email like the one below.
The deployment of this solution will take some time. You can check on the progress using the Bell icon in the top right of the Azure Portal.
Once the deployment has finished you can sit back and let your VMs stop and start with your schedule.
Check the solution
If you would like to view your new Start/Stop solution. Click on All services and then search for Solutions
You should then be able to locate the solution. It will start with Start-Stop-VM and it will look like the image below.
Configure Email Notifications
If you would like to change the email address or add another you will need to change the action group that was created during the deployment.
In the Azure Portal navigate to Monitor and then click Action Groups
Locate and click on the StartSTop_VM_notification group and click Edit details
Here you can edit the email address, or even add alternative methods of contact, like SMS etc.
If you would like to have multiple email address you will need to add extra actions or use a distribution email address like I have.
I hope you found this article helpful. If you have any questions please reach out in the normal methods.