Preparing AZ-104 : Creating Resource group from PowerShell and related CMDLETs – Azure Administration

Hi All,
Greetings for the day!!!
In this article we will discuss how to create Resource group using PowerShell
We have detailed article to start with AZURE PowerShell if you are new to AZURE PowerShell. Please have a look – Configure PowerShell For Microsoft Azure Az Module AND Azure PowerShell – Knowing the basics and starting with few important CMDLETS
What is Resource Group
- If you are new to AZURE and dont know about Resource Groups, we have a very good article. Kindly please have a look – Azure – Resource and Resource group
- Resource Group is container for related AZURE resources
- Resource Group stores metadata about resources
- Location of resource group determines where the metadata of resources will be stored
POWERSHELL CMDLET to create resource group
- Currently there is only one resource group – “rg-azure-dev-centralindia-001” in my environment as
- PowerShell CMDLET for creating new resource group is – New-AzResourceGroup
- Syntax
New-AzResourceGroup
[-Name] <String>
[-Location] <String>
[-Tag <Hashtable>]
[-Force]
[-ApiVersion <String>]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
- Example
New-AzResourceGroup -Name rg-azure-dev-centralindia-002 -Location "Central India"
- The above command creates empty resource group – no resources in it
- We could check the resource listing and see the newly created resource – “rg-azure-dev-centralindia-002” group as
- Make sure we are using proper naming conventions. We have detailed article on AZURE resources naming conventions – Azure – Naming conventions to resources – Best Practices
- By clicking on respective resource group we could see the details as

Other Resource Group PowerShell CMDLETs
- List All Resource Groups in current subscription – Get-AzResourceGroup
Get-AzResourceGroup
[[-Name] <String>]
[[-Location] <String>]
[-Id <String>]
[-Tag <Hashtable>]
[-ApiVersion <String>]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
- We can get specific resource group details as well as
- Remove Resource Group from current subscription –Remove-AzResourceGroup – removes resource group and its resources from current subscription
Remove-AzResourceGroup
[-Name] <String>
[-Force]
[-AsJob]
[-ApiVersion <String>]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
-Id <string>
- When we execute the command we get prompt as shown in below fig
- To avoid prompt we could use “Force” attribute as
Get-AzResourceGroup -Name "rg-azure-dev-centralindia-003" | Remove-AzResourceGroup -Force
REFERENCES
- Configure PowerShell For Microsoft Azure Az Module
- Azure PowerShell – Knowing the basics and starting with few important CMDLETS
- AZURE PowerShell – PowerShell CMDLETs for Azure Subscription – Azure Administration
- Azure – Resource and Resource group
- Azure – Naming conventions to resources – Best Practices
Thanks for reading. If its worth, kindly please like and share 🙂
HAVE A WONDERFUL TIME AHEAD 🙂
You must log in to post a comment.