@@ -84,11 +84,13 @@ if (!$PSBoundParameters.ContainsKey('ErrorAction')) {
8484 $ErrorActionPreference = ' Stop'
8585}
8686
87- function Log ($Message ) {
87+ function Log ($Message )
88+ {
8889 Write-Host (' {0} - {1}' -f [DateTime ]::Now.ToLongTimeString(), $Message )
8990}
9091
91- function Retry ([scriptblock ] $Action , [int ] $Attempts = 5 ) {
92+ function Retry ([scriptblock ] $Action , [int ] $Attempts = 5 )
93+ {
9294 $attempt = 0
9395 $sleep = 5
9496
@@ -109,7 +111,20 @@ function Retry([scriptblock] $Action, [int] $Attempts = 5) {
109111 }
110112}
111113
112- function MergeHashes ([hashtable ] $source , [psvariable ] $dest ) {
114+ function LoadCloudConfig ([string ] $env )
115+ {
116+ $configPath = " $PSScriptRoot /clouds/$env .json"
117+ if (! (Test-Path $configPath )) {
118+ Write-Warning " Could not find cloud configuration for environment '$env '"
119+ return @ {}
120+ }
121+
122+ $config = Get-Content $configPath | ConvertFrom-Json - AsHashtable
123+ return $config
124+ }
125+
126+ function MergeHashes ([hashtable ] $source , [psvariable ] $dest )
127+ {
113128 foreach ($key in $source.Keys ) {
114129 if ($dest.Value.ContainsKey ($key ) -and $dest.Value [$key ] -ne $source [$key ]) {
115130 Write-Warning (" Overwriting '$ ( $dest.Name ) .$ ( $key ) ' with value '$ ( $dest.Value [$key ]) ' " +
@@ -119,7 +134,8 @@ function MergeHashes([hashtable] $source, [psvariable] $dest) {
119134 }
120135}
121136
122- function BuildBicepFile ([System.IO.FileSystemInfo ] $file ) {
137+ function BuildBicepFile ([System.IO.FileSystemInfo ] $file )
138+ {
123139 if (! (Get-Command bicep - ErrorAction Ignore)) {
124140 Write-Error " A bicep file was found at '$ ( $file.FullName ) ' but the Azure Bicep CLI is not installed. See https://aka.ms/install-bicep-pwsh"
125141 throw
@@ -492,6 +508,8 @@ try {
492508 $templateParameters.Add (' testApplicationSecret' , $TestApplicationSecret )
493509 }
494510
511+ $defaultCloudParameters = LoadCloudConfig $Environment
512+ MergeHashes $defaultCloudParameters $ (Get-Variable templateParameters)
495513 MergeHashes $ArmTemplateParameters $ (Get-Variable templateParameters)
496514 MergeHashes $AdditionalParameters $ (Get-Variable templateParameters)
497515
0 commit comments