Invoke-AzResourceGroupDeployment
Synopsis
Deploys resources to a resource group.
Syntax
Invoke-AzResourceGroupDeployment
[-ResourceGroupName] <String>
[-TemplateFile] <String>
[-TemplateUri] <String>
[-TemplateObject] <Object>
[-TemplateParameterFile] <String>
[-TemplateParameterObject] <Object>
[-WhatIf]
[-Confirm]
[None]
Description
The Invoke-AzResourceGroupDeployment cmdlet deploys resources to a resource group from a template. You can specify the template as a file, a URI, or a PowerShell object.
This cmdlet supports deploying resources using Azure Resource Manager (ARM) templates. You can define your infrastructure as code and deploy it consistently across your Azure environment.
Parameters
-
-ResourceGroupName
[String]
Specifies the name of the resource group where the resources will be deployed.
-
-TemplateFile
[String]
Specifies the path to the template file.
-
-TemplateUri
[String]
Specifies the URI of the template.
-
-TemplateObject
[Object]
Specifies the template as a PowerShell object.
-
-TemplateParameterFile
[String]
Specifies the path to the template parameter file.
-
-TemplateParameterObject
[Object]
Specifies the template parameters as a PowerShell object.
-
-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.
Notes
You must provide one of the following template parameters: -TemplateFile, -TemplateUri, or -TemplateObject.
You can also provide parameters for the deployment using -TemplateParameterFile or -TemplateParameterObject.
Examples
Example 1: Deploying a virtual machine from a template file
This example deploys a virtual machine to the 'MyResourceGroup' resource group using a local template file and parameters.
Invoke-AzResourceGroupDeployment -ResourceGroupName "MyResourceGroup" -TemplateFile "C:\Templates\vm-template.json" -TemplateParameterFile "C:\Templates\vm-parameters.json"
Example 2: Deploying from a template URI with inline parameters
This example deploys a storage account from a public template URI and defines parameters directly in the command.
$parameters = @{
"storageAccountType" = "Standard_LRS"
"location" = "East US"
}
Invoke-AzResourceGroupDeployment -ResourceGroupName "MyStorageRG" -TemplateUri "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-storage-account/azuredeploy.json" -TemplateParameterObject $parameters
Example 3: Simulating a deployment without making changes
This example uses the -WhatIf parameter to simulate the deployment without actually creating or modifying any resources.
Invoke-AzResourceGroupDeployment -ResourceGroupName "MyTestRG" -TemplateFile ".\simple-template.json" -WhatIf