New-AzureRmResourceGroup

Creates an Azure resource group.

Warning

The AzureRM PowerShell module has been officially deprecated as of February 29, 2024. Users are advised to migrate from AzureRM to the Az PowerShell module to ensure continued support and updates.

Although the AzureRM module may still function, it's no longer maintained or supported, placing any continued use at the user's discretion and risk. Please refer to our migration resources for guidance on transitioning to the Az module.

Syntax

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

Description

The New-AzureRmResourceGroup cmdlet creates an Azure resource group. You can create a resource group by using just a name and location, and then use the New-AzureRmResource cmdlet to create resources to add to the resource group. To add a deployment to an existing resource group, use the New-AzureRmResourceGroupDeployment cmdlet. To add a resource to an existing resource group, use the New-AzureRmResource 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

PS> New-AzureRmResourceGroup -Name RG01 -Location "South Central US"

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

Example 2: Create an empty resource group using positional parameters

PS> New-AzureRmResourceGroup RG01 "South Central US"

This command creates a resource group that has no resources.

Example 3: Create a resource group with tags

PS> New-AzureRmResourceGroup -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.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

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

Type:IAzureContextContainer
Aliases:AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Force

Forces the command to run without asking for user confirmation.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters: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-AzureRmResourceProvider cmdlet with the ProviderNamespace parameter.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters: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.

Type:String
Aliases:ResourceGroupName
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Pre

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

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters: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-AzureRmResource and Get-AzureRmResourceGroup 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-AzureRMTag cmdlet.

Type:Hashtable
Aliases:Tags
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-WhatIf

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

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

None

Outputs

Microsoft.Azure.Commands.ResourceManagement.Models.PSResourceGroup