This week I am attending the AZ-104 training where I personally have some specific interest in Azure PowerShell were the training itself is actually more focused on administrating.
In several occasions, I have find myself questioning whether I have to revise my knowledge of PowerShell or simply over looking something as e.g. the command New-AzResourceGroupDeployment which doesn’t appear to have a -Location1 or -Location2 parameter (also not in the local help) but executes without any error…
New-AzResourceGroupDeployment `
-ResourceGroupName $rgName `
-TemplateFile $HOME/az104-05-vnetvm-loop-template.json `
-TemplateParameterFile $HOME/az104-05-vnetvm-loop-parameters.json `
-location1 $location1 `
-location2 $location2
Where do the Parameters -Location1 and -Location2 in New-AzResourceGroupDeployment come from?
>Solution :
They are dynamic parameters that become available once you have specified a -TemplateFile or -TemplateUri argument, corresponding to the parameters defined in the given template file.
Quoting from the "Description" section of the New-AzResourceGroupDeployment help topic (emphasis added; reformatted):
To use a custom template to create a resource group, specify the
-TemplateFileparameter or-TemplateUriparameter.
Each template has parameters for configurable properties.To specify values for the template parameters, specify the
-TemplateParameterFileparameter or the-TemplateParameterObjectparameter.Alternatively, you can use the template parameters that are dynamically added to the command when you specify a template.
To use dynamic parameters, type them at the command prompt, or type a minus sign (
-) to indicate a parameter and use the Tab key to cycle through available parameters.
Template parameter values that you enter at the command prompt take precedence over values in a template parameter object or file.