I am an Azure rookie. Currently, I have a small cheap VM that is always running, from which I start a big expensive VM via command line (i.e. a simple az vm start -g foo -n bar). However, I am wondering if there is a more elegant way of doing this. Do you have any suggestions?
Important: it should not cost more than 5$/month. My current setup is 'free' because I need the small cheap VM to be running anyway.
I tried the Microsoft's Start/Stop VMs v2 function, which is recommended by Azure. Before deploying it, I tried to figure out the projected cost of this solution. Here is a summary of the components and their prices.
- Functions: Pricing - Functions - the functions have a free monthly buffer of 400kGB-s and 1Mio. executions.
- Logic App: Pricing - Logic Apps - free for our purposes under Consumption Plan
- Storage: Azure Files Pricing - monthly storage costs will be < 1$ as the Start/Stop VM function should need < 1GiB
- Networking: Pricing - Bandwidth - monthly networking costs will be < 1$ as the transferred data size is low for this function
- Application Insights: Pricing - Azure Monitor
- Monitor: see Application Insights
- Dashboard: Unclear, maybe this Pricing - Stream Analytics
Looks great, a neat and elegant solution for 5$/month, exactly what I need, right? BUT: after deploying the function and monitoring the costs, it turns out that the Storage account is by default protected by the Microsoft Defender for Cloud, which was not mentioned anywhere before. This one alone costs over 10$/month. The security layer is of course important. I don't want to sound cheap but those costs accumulate over time and will increase further when scaling up or out.
Thus, back to my question: What would you suggest as the best practice to automatically start/stop a virtual machine in Azure?
Maybe there is another elegant solution that doesn't require navigating through Microsoft's pricing maze.
You can use
Azure Automationto automate the Azure resources using runbooks and create a PowerShell runbooks to start and stop your VM on a schedule by following below steps.Create a Automation account with
System IdentityCreate a Runbook in automation account by navigating to
Runbooks > Create a runbookYou can find the automation account
object IDhere.The VM has been automatically started according to the scheduled time.
Auto-shutdownoption in the VM settings.