I have a PowerShell script for an ARM template to deploy some resources into Azure, more specifically ASE v2.
My ARM template has a condition in it stating:
"sv-ase-version": "v2",
"sv-asp-template-filenameHash": {
"v1": "[concat(variables('sv-baseURI'),concat('/azuredeploy-asp.v1.json',parameters('_artifactsLocationSasToken')))]",
"v2": "[concat(variables('sv-baseURI'),concat('/azuredeploy-asp.json',parameters('_artifactsLocationSasToken')))]"
},
What i have right now in PowerShell:
Param(
[string] $TemplateFile = 'azuredeploy-dev.json',
[string] $TemplateParametersFile = 'azuredeploy-dev.parameters.json',
)
$TemplateFile = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($PSScriptRoot, $TemplateFile))
$TemplateParametersFile = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($PSScriptRoot, $TemplateParametersFile))
What i wanna add in PowerShell is:
Param(
[string] $TemplateFile = 'azuredeploy-dev.json',
[string] $TemplateParametersFile = 'azuredeploy-dev.parameters.json',
[string] $TemplateFilev2 = 'azuredeploy.json',
[string] $TemplateParametersFilev2 = 'azuredeploy.parameters.json',
)
#Checking if this is the correct way to do it
if ("sv-ase-version" -eq "v1") {
$TemplateFile = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($PSScriptRoot, $TemplateFile))
$TemplateParametersFile = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($PSScriptRoot, $TemplateParametersFile))
}
else {
$TemplateFilev2 = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($PSScriptRoot, $TemplateFilev2))
$TemplateParametersFilev2 = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($PSScriptRoot, $TemplateParametersFilev2))
}
My intention: make the switch in the JSON file, without needing to change things in PowerShell.
Would this work? How would you approach this differently?
Thanks.