How to delete ALL Azure resources with powershell

Question:

I need to empty my Azure account from all resources and there’s too much to remove individually in the portal. Looking for a powershell script to do this. Thanks.

Answer:

As resources in Azure are grouped into resource groups(RG), that would probably be the easiest way to go about this. Use these cmdlets to do this.

Once you have retrieved all the RGs, you can pipe the results with the | character to the Remove cmdlet and iterate through them with a ForEach loop. Give it a go, it is the best way to learn, as opposed to simply asking for the solution on here.

Alternatively, if you don’t want to use powershell, just delete your RGs from the portal. I assume you think it would take too long because you are looking at the individual resources and not their RGs, but if you really do have that many RGs, then scripting is best.

Source:

How to delete ALL Azure resources with powershell by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply