New-AzResourceGroupDeployment
The New-AzResourceGroupDeployment cmdlet creates a new deployment of resources to a resource group.
SYNOPSIS
Creates a new deployment of resources to a resource group.
SYNTAX
New-AzResourceGroupDeployment
-ResourceGroupName <String>
[-Name <String>]
[-TemplateFile <String>]
[-TemplateUri <String>]
[-TemplateParameterFile <String>]
[-TemplateParameterObject <Object>]
[-WhatIf]
[-Confirm]
DESCRIPTION
The New-AzResourceGroupDeployment cmdlet creates a new deployment of resources to a resource group. You can specify the deployment template either as a file or a URI, and provide parameters for the template.
PARAMETERS
| Name | Type | Description |
|---|---|---|
| -ResourceGroupName | String | The name of the resource group to deploy to. (Required) |
| -Name | String | The name of the deployment. If not specified, a unique name is generated. |
| -TemplateFile | String | The path to the deployment template file. |
| -TemplateUri | String | The URI of the deployment template. This can be a publicly accessible URL or a URI within Azure. |
| -TemplateParameterFile | String | The path to the file containing the deployment parameters. |
| -TemplateParameterObject | Object | A hashtable or PSCustomObject containing the deployment parameters. |
| -WhatIf | Switch | Shows what would happen if the cmdlet runs. The cmdlet is not run. |
| -Confirm | Switch | Prompts you for confirmation before running the cmdlet. |
EXAMPLES
Example 1: Deploying a template from a local file
New-AzResourceGroupDeployment -ResourceGroupName "MyResourceGroup" -TemplateFile "./azuredeploy.json" -TemplateParameterFile "./azuredeploy.parameters.json"
This command deploys an Azure Resource Manager template from a local file named azuredeploy.json and uses parameters from azuredeploy.parameters.json to create or update resources in the resource group "MyResourceGroup".
Example 2: Deploying a template from a URI
New-AzResourceGroupDeployment -ResourceGroupName "MyResourceGroup" -TemplateUri "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-storage-account-create/azuredeploy.json" -TemplateParameterObject @{storageAccountType = "Standard_LRS"}
This command deploys an Azure Resource Manager template from a public GitHub URI and provides the storage account type parameter directly as an object.
Example 3: Deploying with a specific deployment name
New-AzResourceGroupDeployment -ResourceGroupName "MyResourceGroup" -TemplateFile "./azuredeploy.json" -Name "MyStorageDeployment"
This command deploys a template from a local file to "MyResourceGroup" and assigns the deployment the name "MyStorageDeployment".