>>Making life easier with Azure Automation!!⌗
>>What is it?⌗
The Start/Stop VMs during off-hours solution starts and stops your Azure virtual machines on user-defined schedules, provides insights through Azure Log Analytics, and sends optional emails by using SendGrid. It supports both Azure Resource Manager and classic VMs for most scenarios.
Currently I have a Dev environment that is costing money when its not being used. There is an easy way to “Auto-Shutdown” the VM at a specific time using the Auto-Shutdown Operation within your VM on Azure. Issue is when I come back into the office in the morning I need to login to the Azure Portal and manually turn that VM back on. Not anymore!
>> The Solution⌗
Microsoft have released a solution (In Preview) called “Start/Stop VMs during off-hours”, this essentially lets you schedule time a time that you want your Azure VM’s to power down and when to power back on. Before this you could have done this manually by creating runbooks which essentially are scripts that can be automated to run under a particular condition. With the release of “Start/Stop VM’s during off-hours” this process is massively simplified into completing one deployment which I’ll take you though now.
>>Doing it yourself.⌗
From your Azure Deployment choose “Create a resource” and look for “Start/Stop VM’s during off-hours”. Once you’ve found this you will be prompted to choose and existing or create a new OMS workspace, this is a Operations Management Suite space where you can log analytics about your tenancy/ specific VM’s or applications. Next you will need to have a Automation Account to link to this service. This is an account that will complete your automation tasks for you, this is know as an “Azure Run As Account”. One thing to make sure is that you have the required permission on your tenancy to create these accounts, if not you’ll have to get your internal IT team to step in and create them for you. How to do this can be found on this Technet post. https://docs.microsoft.com/en-us/azure/automation/automation-quickstart-create-account
Once this is done the last things to do is choose your Resource Group that has the VM’s inside you want to shutdown, this is taken as a string so make sure you’re typing your resource group correctly, a VM Exclude, so you can type the names of the VM’s inside of this resource group that you don’t wan to follow this shut off/on policy again this is a string. Note: if you leave the * (wildcard) in the ResourceGroup field then ALL VM’s INSIDE THE SUBSCRIPTION WILL BE TARGETED you’ve been warned.
You can now configure the schedule of when you want the VM’s to shut off and on. At this moment this is set as a daily task.
One option you have is to configure email notifications by using the SendGrid service. There is a free tier which allows you:
Up to 25,000 emails per month. Includes all Bronze Plan features and access to Web, SMTP, Event and Parse APIs
Then press “OK” then press “Create” to deploy your solution.
>>Customizing for yourself⌗
Once your deployment has been fully completed it will auto pin a Solution Tile and Automation Account VM to your Dashboard to easily access the information you need.
Each of the Start/Stop Processes use Runbooks that are stored inside of your Automation Account created earlier. If you open your corresponding Automation Account you can find each Runbook inside of there and you can edit them. Make sure that when you’re editing a Runbook you use the Parent and not a Child version.
The way it is currently configured will start and stop the server at the specified time each day, you can however change this by editing the values inside the Runbook. Once inside choose Schedules from the Resource list on the left and inside you will see both StartVM and Stop VM.
From here you can choose more specifically when this will run. For example I have set mine to run only Monday - Friday. I did this because my Dev environment will only need to be auto start/stop during the week and stay off during the weekends.
I think that this preview item that is now in the Azure dashboard is a nice little feature that can auto start/stop your VM’s when needed. I think it could do with some more features such as a webhook that would be called once the Runbook is complete rather than a email being sent. For more information about this you can follow this link: https://docs.microsoft.com/en-us/azure/automation/automation-solution-vm-management