Azure Subscription Governance

I used Azure Policy to make sure every resource carries an Environment tag. I also set up an Azure Automation runbook that shuts the VM down on a schedule to save cost.

Overview

Here I worked on governance and cost control in my Azure subscription. I assigned the built-in policy Require a tag on resources to my rg-rbac-lab resource group so that every resource must have the tag Environment=Lab. I then deployed an Ubuntu VM with its supporting resources and checked their compliance. Finally I created an Automation Account with a PowerShell runbook that shuts the VM down on a schedule.

What I set out to do

  • Enforce a tagging rule on resources with Azure Policy.
  • Check compliance in the portal, Azure CLI and PowerShell.
  • Shut the VM down automatically on a schedule to control cost.

What I did

  • I reviewed my subscription details with Azure CLI queries and JSON output.
  • I assigned the tag policy to rg-rbac-lab requiring Environment=Lab.
  • I deployed an Ubuntu VM with its network interface, NSG, virtual network and disk.
  • I created the Automation Account aa-rbaclab-shutdown with a system-assigned managed identity. I gave the identity Virtual Machine Contributor on the VM only.
  • I published the Shutdown-VM-Daily-UAE runbook with three daily schedules at 2:00 AM, 5:00 PM and 10:00 PM UAE time.

Screenshots

They are in the same order as in my repository. Click one to see it full size.

I painted over my Azure subscription ID in red. Everything else is as I captured it.

How I tested it

  • Compliance showed all five resources as compliant in the portal, Azure CLI and PowerShell.
  • A runbook job completed and PowerShell showed the VM as deallocated.

Repository

My full notes and the original screenshots are on GitHub: azure-administrator-labs/04-azure-subscription-governance