A resource group is a logical group of resources in Azure. It includes virtual machines, databases, web applications, and storage accounts.
We can delete an Azure resource group using the Remove-AzResourceGroup
cmdlet in PowerShell.
Let's follow the below steps to delete an Azure resource group using PowerShell.
We open PowerShell and install the Az
module using the below cmdlet.
Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force
We log in to our account with the following command.
This command provides a link we can open in the browser. There, we enter the provided code.
Connect-AzAccount -UseDeviceAuthentication
After successfully logging in, we print the Account
, SubscriptionName
, TenantId
, and Environment
.
Now, we can delete the resource group using the below command. We need to pass the resource group's name as a parameter to the Remove-AzResourceGroup
cmdlet.
Remove-AzResourceGroup "resource group name"
We can also provide the -Force
parameter to disable the confirmation prompts.
Note: Deleting the resource group deletes all resources present in it. To be careful in the production environment, it is not recommended that we use the
-Force
parameter.
Let's connect to the terminal below and execute the commands discussed above.
Free Resources