Hello,
A few days ago I encountered a problem when I wanted to use a workspace specific Parameter file. What happens is that when I run the workflow it fails the deployment due to missing parameter files. After some Debugging I found the problem.
The problamatic code can be found in the second line of the AttemptDeployment function:
function AttemptDeployment($path, $parameterFile, $deploymentName, $templateObject) {
Write-Host "[Info] Deploying $path with deployment name $deploymentName"
$isValid = IsValidTemplate $path $templateObject <-- this line
if (-not $isValid) {
return $false
}
...
Looking at the line or inside the IsValidTemplate function we can see that it doesn't obtain the parameter file that goes with the given template.
To fix this you need to modify the script a bit:
IsValidTemplate
function IsValidTemplate($path, $templateObject, $parameterFile) {
Try {
if (DoesContainWorkspaceParam $templateObject) {
if($parameterFile)
{
Test-AzResourceGroupDeployment -ResourceGroupName $ResourceGroupName -TemplateFile $path -TemplateParameterFile $parameterFile -workspace $WorkspaceName
}
else{
Test-AzResourceGroupDeployment -ResourceGroupName $ResourceGroupName -TemplateFile $path -workspace $WorkspaceName
}
}
else {
if($parameterFile)
{
Test-AzResourceGroupDeployment -ResourceGroupName $ResourceGroupName -TemplateFile $path -TemplateParameterFile $parameterFile
}
else{
Test-AzResourceGroupDeployment -ResourceGroupName $ResourceGroupName -TemplateFile $path
}
}
return $true
}
Catch {
Write-Host "[Warning] The file $path is not valid: $_"
return $false
}
}
AttemptDeployment
function AttemptDeployment($path, $parameterFile, $deploymentName, $templateObject) {
Write-Host "[Info] Deploying $path with deployment name $deploymentName"
$isValid = IsValidTemplate $path $templateObject $parameterFile
if (-not $isValid) {
return $false
}
...
I have no clue where I can report this bug so I just post it here.
Hello,
A few days ago I encountered a problem when I wanted to use a workspace specific Parameter file. What happens is that when I run the workflow it fails the deployment due to missing parameter files. After some Debugging I found the problem.
The problamatic code can be found in the second line of the
AttemptDeploymentfunction:Looking at the line or inside the
IsValidTemplatefunction we can see that it doesn't obtain the parameter file that goes with the given template.To fix this you need to modify the script a bit:
IsValidTemplateAttemptDeploymentI have no clue where I can report this bug so I just post it here.