Skip to main content
Azure Firewall is billed for every hour it is deployed, on top of the data it processes. A firewall can be deallocated and allocated again from a script, keeping its configuration. nOps finds non-production firewalls that run 24 hours a day, every day, and estimates the saving from running them only during working hours: 12 hours a day on weekdays, 60 hours a week.

Why it matters

A firewall in a development or test network often costs as much as one in production, but nobody uses it at night or at weekends.

How nOps finds it

nOps reads the last 14 complete days of pay-as-you-go Azure Firewall billing. A firewall counts as non-production when at least 90% of its cost carries a non-production environment tag, nOps environment or resource group name. It is flagged when it was deployed for at least 23.5 hours on at least 13 of the 14 days, including at least 3 of the 4 weekend days. The saving is its deployment cost over the last 7 days, scaled to a month, times 1 minus 60/168. Data processing charges are not counted. Firewalls mostly covered by commitments, and savings under $25 a month, are left out.

Before you start

An Azure Automation account (or another scheduler) with permission to change the firewall, and agreement from the environment’s users on working hours.

How to implement

  1. Agree the working hours with the teams that use the environment.
  2. Create two Azure Automation runbooks in PowerShell. To stop the firewall, get it with Get-AzFirewall, call $azfw.Deallocate() and save it with Set-AzFirewall. To start it, call $azfw.Allocate($vnet, $publicIp) with its virtual network and public IP, then Set-AzFirewall.
  3. Schedule the stop runbook for the end of the working day and the start runbook for the start of it, on weekdays only.
  4. Check after a week that the firewall is deallocated outside working hours and that traffic flows when it starts again.

Risks and considerations

  • While the firewall is deallocated, traffic routed through it stops. Anything that runs at night, such as builds or backups, fails unless it is moved to working hours.
  • Starting a firewall takes several minutes, so schedule it to start before people need it.
  • The firewall’s rules and public IP configuration are kept while it is deallocated. To roll back, remove the schedules.

FAQs

nOps assumes the firewall runs 12 hours a day on the 5 weekdays. If your teams need longer hours, the saving is smaller.