Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

New-AzResource

Creates a resource.

Syntax

ByResourceId (Default)

New-AzResource
 -ResourceId <String>
 [-Location <String>]
 [-Kind <String>]
 [-Properties <PSObject>]
 [-Plan <Hashtable>]
 [-Sku <Hashtable>]
 [-Tag <Hashtable>]
 [-IsFullObject]
 [-AsJob]
 [-ODataQuery <String>]
 [-Force]
 [-ApiVersion <String>]
 [-Pre]
 [-DefaultProfile <IAzureContextContainer>]
 [-WhatIf]
 [-Confirm]
 [<CommonParameters>]

BySubscriptionLevel

New-AzResource
 -ResourceName <String>
 -ResourceType <String>
 [-Location <String>]
 [-Kind <String>]
 [-Properties <PSObject>]
 [-Plan <Hashtable>]
 [-Sku <Hashtable>]
 [-Tag <Hashtable>]
 [-IsFullObject]
 [-AsJob]
 [-ExtensionResourceName <String>]
 [-ExtensionResourceType <String>]
 [-ODataQuery <String>]
 [-ResourceGroupName <String>]
 [-Force]
 [-ApiVersion <String>]
 [-Pre]
 [-DefaultProfile <IAzureContextContainer>]
 [-WhatIf]
 [-Confirm]
 [<CommonParameters>]

ByTenantLevel

New-AzResource
 -ResourceName <String>
 -ResourceType <String>
 [-Location <String>]
 [-Kind <String>]
 [-Properties <PSObject>]
 [-Plan <Hashtable>]
 [-Sku <Hashtable>]
 [-Tag <Hashtable>]
 [-IsFullObject]
 [-AsJob]
 [-ExtensionResourceName <String>]
 [-ExtensionResourceType <String>]
 [-ODataQuery <String>]
 [-TenantLevel]
 [-Force]
 [-ApiVersion <String>]
 [-Pre]
 [-DefaultProfile <IAzureContextContainer>]
 [-WhatIf]
 [-Confirm]
 [<CommonParameters>]

Description

The New-AzResource cmdlet creates an Azure resource, such as a website, Azure SQL Database server, or Azure SQL Database, in a resource group.

Examples

Example 1: Create a resource

New-AzResource -Location "West US" -Properties @{test="test"} -ResourceName TestSite06 -ResourceType microsoft.web/sites -ResourceGroupName ResourceGroup11 -Force

This command creates a resource that is a website in ResourceGroup11.

Example 2: Create a resource using splatting

$prop = @{
 Location = "West US"
 Properties = @{test = "test"}
 ResourceName = "TestSite06"
 ResourceType = "microsoft.web/sites"
 ResourceGroupName = "ResourceGroup11"
 Force = $true
}

New-AzResource @prop

This command creates a resource that is a website in ResourceGroup11.

Parameters

-ApiVersion

Specifies the version of the resource provider API to use. If you do not specify a version, this cmdlet uses the latest available version.

Parameter properties

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

Parameter sets

-AsJob

Run cmdlet in the background

Parameter properties

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

Parameter sets

-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

-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

-ExtensionResourceName

Specifies the name of an extension resource for the resource. For instance, to specify a database, use the following format: server name/database name

Parameter properties

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

Parameter sets

-ExtensionResourceType

Specifies the resource type for an extension resource. For instance, if the extension resource is a database, specify the following type: Microsoft.Sql/Servers/Databases

Parameter properties

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

Parameter sets

-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

-IsFullObject

Indicates that the object that the Properties parameter specifies is the full object.

Parameter properties

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

Parameter sets

-Kind

Specifies the resource kind for the resource.

Parameter properties

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

Parameter sets

-Location

Specifies the location of the resource. Specify data center location, such as Central US or Southeast Asia. You can place a resource in any location that supports resources of that type. Resource groups can contain resources from different locations. To determine which locations support each resource type, use the Get-AzLocation cmdlet.

Parameter properties

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

Parameter sets

-ODataQuery

Specifies an Open Data Protocol (OData) style filter. This cmdlet appends this value to the request in addition to any other filters.

Parameter properties

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

Parameter sets

-Plan

A hash table that represents resource plan properties.

Parameter properties

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

Parameter sets

-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

-Properties

Specifies resource properties for the resource. Use this parameter to specify the values of properties that are specific to a resource type.

Parameter properties

Type:PSObject
Default value:None
Supports wildcards:False
DontShow:False
Aliases:PropertyObject

Parameter sets

-ResourceGroupName

Specifies the name of the resource group where this cmdlet creates the resource.

Parameter properties

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

Parameter sets

-ResourceId

Specifies the fully qualified resource ID, including the subscription, as in the following example: /subscriptions/subscription ID/providers/Microsoft.Sql/servers/ContosoServer/databases/ContosoDatabase

Parameter properties

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

Parameter sets

-ResourceName

Specifies the name of the resource. For instance, to specify a database, use the following format: ContosoServer/ContosoDatabase

Parameter properties

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

Parameter sets

-ResourceType

Specifies the type of the resource. For instance, for a database, the resource type is as follows: Microsoft.Sql/Servers/Databases

Parameter properties

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

Parameter sets

-Sku

A hash table that represents sku properties.

Parameter properties

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

Parameter sets

-Tag

Key-value pairs in the form of a hash table. For example: @{key0="value0";key1=$null;key2="value2"}

Parameter properties

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

Parameter sets

-TenantLevel

Indicates that this cmdlet operates at the tenant level.

Parameter properties

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

Parameter sets

-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

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

Hashtable

String

Outputs

PSObject

Related Links


Feedback

Was this page helpful?