I am trying to override some properties in a template parameter file in a powershell script then pass the object to the Test-AzureRmResourceGroupDeployment
cmdlet to test it. The following works;
Test-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateFile 'template.json' -TemplateParameterFile 'parameters.json'
However, it does not work when I load the parameters and pass the object;
$params = Get-Content 'parameters.json' | Out-String | ConvertFrom-Json | ConvertPSObjectToHashtable
Test-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateFile 'template.json' -TemplateParameterObject $params.parameters
The ConvertPSObjectToHashtable
function is one I got from here.
When I run the second command, I get the following error;
Code : InvalidTemplate
Message : Deployment template validation failed: 'The provided value for the template parameter 'location' at line '7' and column '22' is not valid.'.
Details :
Why doesn't it accept the parameters object, and how do I fix it?