Thursday, June 9, 2016

Azure – Removing / Deleting Resource Group with PowerShell

Since Azure introduced the new portal, the recommendation to create is as below :

  1. Create Resource Group
  2. Create Azure Storage Account
  3. Create Azure VNET

That is the 3 basic items that MUST be created first before creating any VMs.

So now I face the “horror of cleaning up” after conducting some demos. The cleaning up is quite a challenge through the GUI Management Portal.  Therefore I need to clear the entire Resource Group.  Before I can delete that, I need to delete all the contents in the resource group. It’s very tedious.

Now I’ve found a way that I would like to share.

Step 1

Update your local PowerShell with the Azure SDK.   If not download it from here.

[image12.png]

Step 2

Once it’s installed, then you should have the Azure commands added into your PowerShell.

Launch the Run ISE as Administrator

Minimize the PowerShell Window.

Step 3

SNAGHTML5584fe7

  • Expand the left panel
  • Browse to the Resource Group

SNAGHTML5603fb3

  • Take note of the PowerShell command (which is going to help later).

Step 4

  • Maximize the PowerShell that was launch earlier (ISE) in Step 2
  • Login using the command of Login-AzureRMAccount

SNAGHTML562ddbf

  • Take note of the SubscriptionId
  • The command to remove the entire Resource Group is as follow :

Remove-AzureRMResource –ResourceId /subscriptions/SubscriptionId/resourceGroups/resourcegroupname/ –ApiVersion 2014-04-01 –Force

Note : Only make changes to the pink colour syntax.  The first is your subscription ID information that you get from the top when you login to Azure and the second one is the resource group name. 

  • If you’re not so sure of the command, then refer to the command that you noted earlier in Step 3 from the Azure Resource Explorer.
  • As example I would like to delete off the entire Resource Group of RG-CANADA-CENTRAL-01 in my subscription then I type the following :

image

  • Once it’s completed removing the Resource Group, a True word is indicated.

image

So hopefully the above helps you as it has helped me in cleaning up the Resource Group.

keywords : azure, resource explorer, manage azure, azure portal , resource group, housekeeping resource group, new azure portal, manage azure portal

3 comments: