New-AzResource
Creates or updates a resource.
SYNOPSIS
Creates a resource in Azure Resource Manager.
SYNTAX
New-AzResource
-Location "<String>"
-ResourceName "<String>"
-ResourceType "<String>"
-ResourceGroupName "<String>"
[-ApiVersion "<String>"]
[-Force]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
DESCRIPTION
The New-AzResource cmdlet creates a resource in Azure Resource Manager.
This cmdlet supports creating a resource of any type that is supported by Azure Resource Manager.
PARAMETERS
| Name | Type | Description |
|---|---|---|
| -Location | String |
Specifies the location for the resource. |
| -ResourceName | String |
Specifies the name of the resource. |
| -ResourceType | String |
Specifies the type of the resource. Example: Microsoft.Storage/storageAccounts |
| -ResourceGroupName | String |
Specifies the name of the resource group to which the resource belongs. |
| -ApiVersion | String |
Specifies the API version to use for the resource type. If not specified, the latest stable API version is used. |
| -Force | SwitchParameter |
Suppresses confirmation prompts. |
| -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.
OUTPUTS
Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkModels.PSResource object.
EXAMPLES
Example 1: Create a storage account
# Create a resource group if it doesn't exist
New-AzResourceGroup -Name "MyResourceGroup" -Location "East US"
# Create a storage account
New-AzResource -ResourceGroupName "MyResourceGroup" -ResourceName "mystorageaccount123" -ResourceType "Microsoft.Storage/storageAccounts" -Location "East US" -ApiVersion "2019-06-01"
Example 2: Create a virtual network with confirmation
New-AzResource -ResourceGroupName "MyVNetResourceGroup" -ResourceName "MyVirtualNetwork" -ResourceType "Microsoft.Network/virtualNetworks" -Location "West US" -ApiVersion "2020-05-01" -Confirm