trying to do some extra tweaks to my ps1 script that deploys vm by using an arm template.
the script asks if an availability zone is needed, if yes then gives you the zone options available. if its not needed, then the $zone variable is set to defaultvalue or null, and then that value is used in the arm template to deploy a vm without any availability zones.
my template.json file contains the following parameter for the zone.
"zone": {
"type": "string",
"defaultValue": {}
}
PS1 script has the following
Write-Host "================ Availability Zone ================" -ForegroundColor Cyan
Write-Host "Is a Availability Zone needed?"
$zonequestion = Read-Host "Enter Yes or No"
if ($zonequestion -eq 'Y' -or $zonequestion -eq 'Yes' )
{
Write-Host "*** Availability Zones ***" -ForegroundColor Green
Write-Host "1: Zone 1"
Write-Host "2: Zone 2"
Write-Host "3: Zone 3"
Write-Host ""
Write-Host "Q: Press 'Q' to quit."
$selection = Read-Host "Select Availability Zone"
switch ($selection)
{
'1' { $Zone = '1' }
'2' { $Zone = '2' }
'3' { $Zone = '3' }
'q' { exit }
}
}
else
{
$Zone = ""
Write-Host "Availability zone is not needed, continuing with deployment"
write-host "zone is " $Zone
}
how do i get the $zone variable to be passed through as the defaultvalue/null so that the template knows that there are no availability sets to be deployed with the VM.
is this possible?
let me know if you need any more info
cheers!