Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ruevaughn/7a12316338f654c8fe85b94c0fe23dbb to your computer and use it in GitHub Desktop.
Save ruevaughn/7a12316338f654c8fe85b94c0fe23dbb to your computer and use it in GitHub Desktop.
Azure cleaning commands

Public IPs

az resource delete --ids $(az network public-ip list --query '[?ipAddress==`null`].[id]' -o tsv)

Network Security Groups

az resource delete --ids $(az network public-ip list --query '[?ipAddress==`null`].[id]' -o tsv)

Network Interfaces

az resource delete --ids $(az network nic list --query '[?virtualMachine==`null` && privateEndpoint==`null`].[id]' -o tsv)

Disks

az resource delete --ids $(az disk list --query '[?managedBy==`null`].[id]' -o tsv)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment