Skip to content

Instantly share code, notes, and snippets.

@six2dez
Created May 23, 2023 09:02
Show Gist options
  • Save six2dez/b0954bbb90c1822c2b22ea6e277b1436 to your computer and use it in GitHub Desktop.
Save six2dez/b0954bbb90c1822c2b22ea6e277b1436 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