New-AzResourceGroup

Edit on GitHub

Cmdlet in Az.Resources module

SYNTAX


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

DESCRIPTION

The New-AzResourceGroup cmdlet creates a resource group in Azure Resource Manager.

A resource group is a logical container for Azure resources. The following example creates a resource group named MyResourceGroup that has the location West US.

PARAMETERS

Parameter Description Required?
-Name Specifies the name of the resource group to create. The name must be unique for your subscription. Yes
-Location Specifies the Azure region where the resource group is created. Example: West US, East US, North Europe. Yes
-Tag Specifies tags to assign to the resource group. Tags are name-value pairs that help you categorize resources. You can specify tags as a hash table. For example, @{Environment="Production"; Project="AzureMigration"}. No
-Force Suppresses the confirmation prompt for creating the resource group. Use this parameter when you are scripting the cmdlet and do not want to be prompted for confirmation. No
-AsJob Runs the cmdlet as a background job. Use this parameter to manage the job and check its status. No
-WhatIf Shows what would happen if the cmdlet runs. The cmdlet is not run. No
-Confirm Prompts you for confirmation before running the cmdlet. No

EXAMPLES

Example 1: Create a resource group


New-AzResourceGroup -Name "MyResourceGroup" -Location "West US"
                    

This command creates a resource group named "MyResourceGroup" in the "West US" region.

Example 2: Create a resource group with tags


$tags = @{
    Environment = "Development"
    Project     = "WebPortal"
}
New-AzResourceGroup -Name "MyTaggedResourceGroup" -Location "East US" -Tag $tags
                    

This command creates a resource group named "MyTaggedResourceGroup" in the "East US" region and assigns two tags: "Environment" set to "Development" and "Project" set to "WebPortal".

Example 3: Create a resource group without confirmation


New-AzResourceGroup -Name "FastResourceGroup" -Location "North Europe" -Force
                    

This command creates a resource group named "FastResourceGroup" in the "North Europe" region without prompting for confirmation.

INPUTS

None. You can pipe to this cmdlet.

OUTPUTS

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

This cmdlet returns a resource group object.

Note

You can get a list of available Azure locations by running Get-AzLocation.

Important

Resource group names must be unique within your Azure subscription. If a resource group with the specified name already exists, the cmdlet will return an error.