I am using PowerShell ISE to recreate an existing database using the script generated in the Azure Portal for the resource. I discovered that PS, does not use the script path, so I added these lines at the top:
Write-Host $PSScriptRoot
Push-Location $PSScriptRoot
Write-Host "Path: $(get-location)"
I added some testing code to make sure the template.json and parameters.json are present and that is working:
# Start the deployment
Write-Host "Starting deployment...";
Write-Host "Testing: $templateFilePath"
if(Test-Path $templateFilePath) {
Write-Host "FOUND: $templateFilePath"
if(Test-Path $parametersFilePath) {
Write-Host "FOUND: $parametersFilePath"
New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateFile $templateFilePath -TemplateParameterFile $parametersFilePath;
} else {
New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateFile $templateFilePath;
}
}
However, the script is still ignoring the defaultValue parameters in template.json:
"advisors_DropIndex_name": {
"defaultValue": "DropIndex",
"type": "String"
},
parameters.json:
"advisors_DropIndex_name": {
"value": null
},
The script returns the following:
New-AzureRmResourceGroupDeployment : 5:17:30 PM - Error: Code=InvalidDeploymentParameterValue; Message=The value of deployment parameter 'keys_ServiceManaged_name' is null. Please specify the value or use the parameter reference. See https://aka.ms/arm-deploy/#parameter-file for details. At C:\Users\longoj\Downloads\ExportedTemplate-DEEAResourceGroup\deploy.ps1:110 char:9 + New-AzureRmResourceGroupDeployment -ResourceGroupName $resour ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet
If set the value in parameters.json:
"advisors_DropIndex_name": {
"value": "DropIndex"
},
the script validation moves on to the next parameter, and there are a lot of them. So it looks like the template.json file's defaultvalue parameter is being ignored.
I am using:
Version : 5.1.2
Name : Azure
Author : Microsoft Corporation
PowerShellVersion : 3.0
What am I doing wrong ?