Any entity that you create in Azure is called Resource. As the name says Resource Group is a group of resources of a similar kind. We can relate this to a folder where we keep all the related files and folders. Resource Group is a container of resources that holds a common life cycle.

Resource Group is a logical collection of resources of the same category. Categorization can be based on Location, Central US, South India, Environments like (Dev, Prod..etc) or Business units (Fin, IT, HR, etc) or Applications type ( DB, Web, ..etc).

Resource Group can be used to control access by RBAC (Role-Based Access Control), assign policies, Cost Analysis and Deployment.

Like any resource that you create in Azure, Resource Group also needs Location where schema related the Resource group will be stored. Resource groups should be created before resource creation.

To create a Resource Group Logon to Azure Portal Search of a Service called Resource Group.

Click on + Add which will launch Resource Group creation blade.

Select Subscription, provide Resource Group name and region/location where the schema of the resource group should reside.

We are not going to discuss Tags now, goto review + create which validates the data provided. If all is good Validation passed message will be displayed in green. If there are any error need to fix them for successful validation.

Use Create option for the creation of Resource Group.

Successful creation of Resource Group will be notified (Check for bell Icon in the portal to see current or past notifications).

Navigate to Resource Group service and select Resource Group created, you see it as below.




Below are the Powershell commands related to Resource Group.

Powershell commands that are used for the creation/deletion of ResourceGroups don’t have Subscription as a parameter. If there are multiple Subscriptions use the Select-Subscription command to select the Subscription on which you would like to work with ResourceGroups.

Get the list of Subscriptions:

Get-Subscription

Switch between Subscriptions:

Select-AzSubscription -Subscription Subscriptionname 

Creation of Resource Group “MyRG”:

New-AzResourceGroup -Name MyRG -Location ‘Central US’ 

Remove  Resource Group “MyRG”:

Remove-AzResource -Name MyRG

Get the Resource Groups in current Subscription: 

Get-AzResourceGroup 

Remove all the Resource Groups in the current Subscription: 

$getrg = Get-AzResourceGroup
foreach($rg in $getrg)
{
$rg ResourceGroupName
Remove-AzResourceGroup -Name $rg.ResourceGroupName -Verbose
}

 or

Get-AzResourceGroup | Remove-AzResourceGroup -Verbose 

Leave a Reply

Your email address will not be published. Required fields are marked *