@Emeric :
I didn't put it in my git yet so don't have a link.. I am adding few things to get started. let me know if that works else, I will update my code and add to my git.
Nonetheless, I can send you few things to get started:
You have 2 files from ADF branch (not the master):
- ARMtemplate.json
- parameters.json
Read the file
$armFile = Get-ChildItem -Path $rootPath -Recurse -Filter "ARMTemplateForFactory.json" | SELECT -First 1
------ > create an empty ARM Template: ARMTemplate_wReplacedValues.json
$armFileWithReplacedValues = $armFile.FullName.Replace($armFile.Name, "ARMTemplate_wReplacedValues.json")
$json = Get-Content $armFile.FullName -raw | ConvertFrom-Json
------ > As you have to use only one parameter for all. You need to create an additional parameter in your new temporary ARM Template.
foreach ($n in $json.parameters) {
$n | Add-Member -Type NoteProperty -Name 'ValueForAll' -Value @{
type= "String"
defaultValue= $valuefromparamtersfile
}
}
------ > Use this to get the exact field from the json
foreach ($n in $json.resources){
$json.update | % { if (<add condition >){
$n.properties.typePropertie = '[parameters(''valuefromparamtersfile'')]'
}
}
}
$json | ConvertTo-Json -depth 100 | Out-file $armFileWithReplacedValues
Try it locally first, before working with build pipeline.
Let me know If that works.
Regards
Pranay