In this blog post How to Shut Down Unused Azure Resources Automatically and Safely we will explain how to stop idle cloud resources, reduce unnecessary spending and avoid shutting down something the business still needs.
The basic idea is simple. Azure checks a schedule or a set of rules, identifies resources approved for shutdown, and turns them off without someone having to remember every evening.
The challenge is deciding what โunusedโ really means. A development server sitting idle overnight is a good candidate. A production server with low activity may be quiet because it is waiting for an important end-of-month process.
Why manual shutdown processes usually fail
Most Azure waste is not caused by one enormous mistake. It comes from ordinary resources that remain online longer than necessary.
A developer creates a virtual machine for a three-week project. A test environment stays online overnight. A proof-of-concept system remains active months after the project ended.
Someone may plan to switch these resources off manually, but business priorities take over. Azure continues charging until somebody notices the growing bill.
If you have not yet identified where the waste is coming from, start with our guide to finding and stopping wasted Azure spending. Once you know which resources are safe candidates, automation makes the savings repeatable.
The technology behind automatic Azure shutdowns
For virtual machines, the simplest option is Azure’s built-in auto-shutdown feature. You choose a time and time zone, and Azure shuts down the machine each day.
For larger environments, Azure Automation provides more control. It runs small scripts called runbooks on a schedule. A runbook is simply a documented set of instructions that Azure follows automatically.
The runbook can look for tags attached to resources. Tags are labels such as Environment=Development, Owner=FinanceIT or AutoShutdown=Enabled.
A managed identity should then give the automation account permission to stop approved resources. This is a secure Azure identity that removes the need to store an administrator’s username and password inside a script.
Choose the right shutdown method
1. Use built-in auto-shutdown for individual virtual machines
This is a good fit when you only have a small number of development, testing or training machines. It is quick to configure and can send a notification before shutdown.
The limitation is that it is managed machine by machine. It also handles shutdown rather than a complete business-hours operating schedule, so you may need a separate automation task to restart the machine in the morning.
2. Use Azure Automation for multiple teams or subscriptions
Azure Automation is better when shutdown rules need to cover dozens of virtual machines, several resource groups or multiple business units. One runbook can find every resource with an approved tag and process it consistently.
Microsoft’s Start/Stop VMs v2 solution is another option for centrally scheduling virtual machines. It is designed for broader environments where start and stop schedules, monitoring and notifications need to be managed together.
3. Use the controls built into each Azure service
Not every Azure resource behaves like a virtual machine. Some services can pause or scale down, while others continue charging even when the application itself is stopped.
- Azure SQL Database serverless can automatically pause its computing capacity after a period without activity and resume when a connection arrives.
- Azure Kubernetes Service, which runs container-based applications, can stop suitable non-production clusters to reduce computing costs.
- Azure App Service requires extra care. Stopping a web application does not necessarily stop charges for the underlying hosting plan. Our guide to lowering Azure App Service costs explains the safer options.
A practical setup using tags and Azure Automation
A reliable shutdown process should be based on clear business rules, not just a script somebody found online.
- Create an ownership list. Every resource should have a business owner, technical owner and environment classification.
- Define approved schedules. Decide which systems can stop overnight, on weekends or after a period of inactivity.
- Add an automation tag. For example, use
AutoShutdown=Enabledonly after the owner has approved it. - Create an Azure Automation account. Enable its managed identity and give it permission only to manage the required virtual machines or resource groups.
- Create and test the runbook. Begin with a small development group before expanding the scope.
- Add monitoring and notifications. Record what was stopped, when it happened and whether any action failed.
The following simplified PowerShell runbook shows the core idea. It connects securely, finds tagged virtual machines that are running, and deallocates them.
param(
[Parameter(Mandatory = $true)]
[string]$SubscriptionId,
[string]$TagName = "AutoShutdown",
[string]$TagValue = "Enabled"
)
Disable-AzContextAutosave -Scope Process
$context = (Connect-AzAccount -Identity).Context
$context = Set-AzContext `
-SubscriptionId $SubscriptionId `
-DefaultProfile $context
$vms = Get-AzVM -Status -DefaultProfile $context | Where-Object {
$_.Tags[$TagName] -eq $TagValue -and
$_.PowerState -eq "VM running"
}
foreach ($vm in $vms) {
Write-Output "Deallocating $($vm.Name)"
Stop-AzVM `
-ResourceGroupName $vm.ResourceGroupName `
-Name $vm.Name `
-Force `
-NoWait `
-DefaultProfile $context
}
This is a starting point rather than a complete production solution. A business-grade runbook should include exclusions, error handling, notifications, maintenance windows and a record of every action.
Make sure the machines are deallocated
There is an important difference between a virtual machine that is stopped and one that is stopped and deallocated. Deallocation releases the computing capacity so Azure no longer charges for that portion of the machine.
Shutting down from inside Windows or Linux can leave the virtual machine in a stopped but still allocated state. That means the server appears off while computing charges may continue.
Even after deallocation, related costs can remain. Managed disks, backups, snapshots, monitoring data, reserved capacity and some network resources may still generate charges.
Automatic shutdown should therefore be combined with safe Azure right sizing and regular storage reviews. Shutdown handles wasted operating hours; it does not fix every source of cloud waste.
Do not automatically shut down based on CPU alone
Low processor use does not always mean a system is unnecessary. File servers, integration services, disaster recovery systems and applications waiting for scheduled work may show very little activity.
Azure Advisor can highlight virtual machines with little or no recent activity, but its recommendations should begin a review rather than automatically trigger shutdown in a production environment.
A safer process is to notify the resource owner, wait for approval, apply the shutdown tag and monitor the first few scheduled stops. Fully automatic action is best reserved for resources with predictable usage, such as development environments and temporary test systems.
What the savings can look like
Consider a 200-person professional services company with 14 development virtual machines. The machines are needed for around 55 hours each week but have been running for all 168 hours.
A weekday start and stop schedule could remove roughly two-thirds of their unnecessary computing hours. If the compute portion of those machines cost $6,000 per month, the gross opportunity could be around $4,000 before allowing for storage, reservations and automation costs.
The larger benefit is control. New development machines can inherit the same tags, schedules and approval process instead of gradually adding another forgotten monthly expense.
Build safety into the automation
- Exclude production systems unless a schedule has been formally approved.
- Use Australian time zones and account for daylight saving changes.
- Send warnings before shutdown where employees may still be connected.
- Test automatic startup and application health, not just shutdown.
- Use the minimum permissions required for the automation identity.
- Review failed jobs and shutdown logs regularly.
- Require owner, environment and shutdown-policy tags through Azure Policy.
These controls matter for security and compliance as well as cost. Clear permissions, change records and ownership support the disciplined access and system management expected under the Essential Eight, the Australian Government’s cybersecurity framework that many organisations are now required to follow.
Turn one-off savings into a permanent cost control
Automatic shutdown works best when it becomes part of how Azure resources are created. Every new non-production resource should have an owner, an expiry date and a decision about whether it needs to run outside business hours.
CloudPro Inc takes this practical approach when helping organisations control Azure costs. As a Microsoft Partner with more than 20 years of enterprise IT experience, our Melbourne-based team designs the schedules, permissions and monitoring around the way each business actually operates.
If you are not sure which Azure resources can be safely shut downโor whether stopped resources are still costing you moneyโwe are happy to take a look at your current setup, with no strings attached.
Discover more from CPI Consulting
Subscribe to get the latest posts sent to your email.