Edit

Share via


New-AzResourceGroup

Creates an Azure resource group.

Syntax

Default (Default)

New-AzResourceGroup
    [-Name] <String>
    [-Location] <String>
    [-Tag <Hashtable>]
    [-Force]
    [-ApiVersion <String>]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

The New-AzResourceGroup cmdlet creates an Azure resource group. You can create a resource group by using just a name and ___location, and then use the New-AzResource cmdlet to create resources to add to the resource group. To add a deployment to an existing resource group, use the New-AzResourceGroupDeployment cmdlet. To add a resource to an existing resource group, use the New-AzResource cmdlet. An Azure resource is a user-managed Azure entity, such as a database server, database, or website. An Azure resource group is a collection of Azure resources that are deployed as a unit.

Examples

Example 1: Create an empty resource group

New-AzResourceGroup -Name RG01 -Location "South Central US"

This command creates a resource group that has no resources. You can use the New-AzResource or New-AzResourceGroupDeployment cmdlets to add resources and deployments to this resource group.

Example 2: Create an empty resource group using positional parameters

New-AzResourceGroup RG01 "South Central US"

This command creates a resource group that has no resources.

Example 3: Create a resource group with tags

New-AzResourceGroup -Name RG01 -Location "South Central US" -Tag @{Empty=$null; Department="Marketing"}

This command creates an empty resource group. This command is the same as the command in Example 1, except that it assigns tags to the resource group. The first tag, named Empty, can be used to identify resource groups that have no resources. The second tag is named Department and has a value of Marketing. You can use a tag such as this one to categorize resource groups for administration or budgeting.

Parameters

-ApiVersion

Specifies the API version that is supported by the resource Provider. You can specify a different version than the default version.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure

Parameter properties

Type:IAzureContextContainer
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzContext, AzureRmContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Force

Forces the command to run without asking for user confirmation.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Location

Specifies the ___location of the resource group. Specify an Azure data center ___location, such as West US or Southeast Asia. You can place a resource group in any ___location. The resource group does not have to be in the same ___location your Azure subscription or in the same ___location as its resources. To determine which ___location supports each resource type, use the Get-AzResourceProvider cmdlet with the ProviderNamespace parameter.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:1
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-Name

Specifies a name for the resource group. The resource name must be unique in the subscription. If a resource group that has that name already exists, the command prompts you for confirmation before replacing the existing resource group.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:ResourceGroupName

Parameter sets

(All)
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-Pre

Indicates that this cmdlet considers pre-release API versions when it automatically determines which version to use.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Tag

Key-value pairs in the form of a hash table. For example: @{key0="value0";key1=$null;key2="value2"} To add or change a tag, you must replace the collection of tags for the resource group. After you assign tags to resources and groups, you can use the Tag parameter of Get-AzResource and Get-AzResourceGroup to search for resources and groups by tag name or by name and value. You can use tags to categorize your resources, such as by department or cost center, or to track notes or comments about the resources. To get your predefined tags, use the Get-AzTag cmdlet.

Parameter properties

Type:Hashtable
Default value:None
Supports wildcards:False
DontShow:False
Aliases:Tags

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

String

Hashtable

Outputs

PSResourceGroup