I was assigned a task to auto shut off the AzureVMs during weekend and start again on Monday.
During my research, I have found numerous articles as I do not want to reinvent the wheel if some one has already written a script or solution for it.
Numerous articles were pointing to Enable Start/Stop VMs during off-hours
But there are few which I got interested in and now sharing a process here as We do not have log analytics enabled.
First as you might have already guessed we will need Azure Automation account. (create one if you do not have)
Go to https://portal.azure.com –> Search for Automation and hit Automation Accounts.
Click ADD, select the subscription and Create Azure Run As Account
Ones automation account is created, go to automation account à Runbooks
Browse gallery and search from Start VM and Stop VM (it will be from Azure Product group)
Click on import to import it to your runbooks. (Name it as per your Naming convention)
Now you can see both the Graphical RunBooks are imported into your Azure Automation Account.
You have to click edit to modify the parameters and to Publish it.
Click on Input and Output, Select the parameter à toggle Default value to custom and add the resource group name where VMs resides.
Hit ok, Save and Publish.
Now click link to Schedule and define the schedule to start VM.
Follow the same steps for STOP VM activity and Schedule the VM to Stop.
You can use this method to stop Azure VMs during offhours or weekends and then start again when required using Start VM schedule.
Thanks for reading…
Tech Wizard