Schedule the Start of a VM in Azure
Background:
I used to carry my MacBook everywhere but not anymore
I used to carry my own personal laptop all around the place, customers, conferences, libraries, etc. In order to have my tool of choice for work. As things have become mobile, the need for a physical device most of the time seems to be unnecessary.
And with the availability of almost “unlimited” resources in the Cloud, I can easily have my own workstation and connect to it wherever I am, whenever I need to.
Having a remote resource hosted in the Cloud has some implications:
- Cost: I really don’t need that much of power, just the standard tools – Office, Visio, Visual Studio, Powershell and the occasional Wireshark, Fiddler, etc. But still has a cost implication
- Patches and updates: Just as any other physical workstation it does require management
- Turning ON and OFF: In order to keep costs under control, I need to run this resource as needed, there’s no point to have it ON during the weekends or after midnight
- A local computer to perform a Remote Desktop Connection to the VM in the Cloud. Again, as I have an almost zero policy for carrying computers and tablets, I have a Surface RT at the Office.
I even enabled the Insider Preview for it
Based on these considerations I decided to run a Windows 10 Pro on Azure, a 2 Core, 16 GB RAM with 125 GB of Disk, not SSD as it’s more expensive and Word doesn’t run faster on it. It’s a Standard D11 in the VM Definition Size
Turn it ON and OFF
This looks just like any other regular set of tasks and they really are. But, sometimes I forget to turn the VM ON, even with the Azure mobile app.
My logic:
- I’d rather automate it and forget about it.
- I arrive at the office and it’s already available to work.
- Not having to log in to the portal or open the app on my iPhone.
- I like the convenience
Steps
- Create an automation Account
- Import the runbook from the marketplace
- Publish the runbook
- Create a schedule
- Tie the Runbook to the schedule
Make sure to select the Run As Account. This will create a “service account” in AAD with privileges to execute the runbook
Import the Runbook
Give it a name
Go to the newly created runbook and click Edit as shown below:
Publish the Runbook
Create a Schedule
I set up a Monday-Friday recurrence starting at 9 am
Tie the Runbook to a schedule. You can create almost any combination of days/dates
Specify the VM parameters
Specify the Resource group and the VM name. If not VM name is specified, all the VMs in the RG will be started
Verify
Once the Runbook runs it’ll generate a log, see below
Startup completed as scheduled
What about the shutdown?
I could’ve used this to automate the shutdown but as the VM itself has that option in the Azure portal I selected that instead
Roberto