New-AzResourceGroup

Creates an Azure resource group.

Syntax

New-AzResourceGroup
   [-Name] <String>
   [-Location] <String>
   [-Tag] <Hashtable>
   [-Force]
   [-AsJob]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

DESCRIPTION

The New-AzResourceGroup cmdlet creates an Azure resource group. A resource group is a logical container that holds Azure resources that are related to each other.

You can use the New-AzResourceGroup cmdlet to create a resource group with a specified name and location, and to assign tags to the resource group.

PARAMETERS

Name Type Description
-Name String Specifies the name of the resource group to create.
-Location String Specifies the Azure region for the resource group. For example, 'East US', 'West Europe', or 'Southeast Asia'.
-Tag Hashtable Specifies tags to assign to the resource group. Tags are name-value pairs that help you categorize and identify resources.
-Force SwitchParameter Suppresses the confirmation prompt. Use this parameter to create the resource group without prompting for confirmation.
-AsJob SwitchParameter Runs the cmdlet as a background job. Use this parameter to run the command and continue working without waiting for the command to complete.
-WhatIf SwitchParameter Shows what would happen if the cmdlet runs. The cmdlet is not run.
-Confirm SwitchParameter Prompts you for confirmation before running the cmdlet.

INPUTS

None. You can pipe to this cmdlet, but you cannot pipe values to parameters.

OUTPUTS

Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkModels.PSResourceGroup

This cmdlet returns a resource group object.

EXAMPLES

Example 1: Create a resource group

This command creates a resource group named 'MyResourceGroup' in the 'East US' region.

PowerShell
New-AzResourceGroup -Name "MyResourceGroup" -Location "East US"

Example 2: Create a resource group with tags

This command creates a resource group named 'MyTaggedResourceGroup' in the 'West Europe' region and assigns two tags: 'Environment' with a value of 'Production' and 'Owner' with a value of 'AdminTeam'.

PowerShell
New-AzResourceGroup -Name "MyTaggedResourceGroup" -Location "West Europe" -Tag @{Environment="Production";Owner="AdminTeam"}

Example 3: Create a resource group without confirmation

This command creates a resource group named 'MyForceGroup' in the 'Southeast Asia' region and suppresses the confirmation prompt.

PowerShell
New-AzResourceGroup -Name "MyForceGroup" -Location "Southeast Asia" -Force

NOTES

Important: Resource group names must be unique within your Azure subscription.

Tip: You can use Get-AzLocation to list available Azure regions.

To create a resource group in the background, use the -AsJob parameter.

RELATED LINKS