Table of Contents
Connect to Microsoft Azure PowerShell
First, you need connect to Microsoft Azure PowerShell, there’re two ways to run PowerShell commands in Microsoft Azure:
Method 1: From Azure PowerShell modules installed in a computer.
Method 2: From Azure Cloud Shell using browsers.
Delete a Azure Resource Group
1. Get the list of resource groups in the current subscription.
Get-AzResourceGroup | FT
ResourceGroupName Location ProvisioningState Tags TagsTable ResourceId
----------------- -------- ----------------- ---- --------- ----------
NetworkWatcherRG eastus Succeeded /subscriptions/089d4ee9-...
cloud-shell-storage-eastus eastus Succeeded /subscriptions/089d4ee9-...
EastUS-RG eastus Succeeded /subscriptions/089d4ee9-...
2. But before using this command, make sure that no usable resources exist in the resource group that you want to delete. To check if the resources are available in the resource group, use the below command. Here we are using the EastUS-RG resource group name.
Get-AzResource -ResourceGroupName "EastUS-RG" | FT
Name ResourceGroupName ResourceType Location
---- ----------------- ------------ --------
vm-001-OS EASTUS-RG Microsoft.Compute/disks eastus
vm-001 EastUS-RG Microsoft.Compute/virtualMachines eastus
vm-001/BGInfo EastUS-RG Microsoft.Compute/virtualMachines/extensions eastus
vm-001-NIC EastUS-RG Microsoft.Network/networkInterfaces eastus
EastUS-vNet-SG EastUS-RG Microsoft.Network/networkSecurityGroups eastus
vm-001-IP EastUS-RG Microsoft.Network/publicIPAddresses eastus
EastUS-vNet EastUS-RG Microsoft.Network/virtualNetworks eastus
3. Once you are confirmed that you need to delete the Resource Group then use the below command to delete the resource group.
Note
When you use the -Force parameter, you won’t be prompted for deletion confirmation.
Remove-AzResourceGroup -Name "eastus-rg" -Verbose
Confirm
Are you sure you want to remove resource group 'eastus-rg'
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"):
VERBOSE: Performing the operation "Removing resource group ..." on target "eastus-rg".
True
ADVERTISEMENT
5/5 - (2 votes)