Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

powershell

How to delete the Azure resource group using PowerShell

Gutha Vamsi Krishna

Overview

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.

Syntax

Remove-AzResourceGroup "resource group  name"

Let's follow the below steps to delete an Azure resource group using PowerShell.

Step 1

We open PowerShell and install the Az module using the below cmdlet.

Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force

Step 2

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 AccountSubscriptionNameTenantId, and Environment.

Step 3

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.

Terminal 1
Terminal

RELATED TAGS

powershell

CONTRIBUTOR

Gutha Vamsi Krishna
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring