Skip to content

Commit 39c0bcb

Browse files
azure-sdkbenbp
andauthored
Add default cloud configuration values to source (#18653)
Co-authored-by: Ben Broderick Phillips <[email protected]>
1 parent d3c1802 commit 39c0bcb

File tree

4 files changed

+60
-4
lines changed

4 files changed

+60
-4
lines changed

eng/common/TestResources/New-TestResources.ps1

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"azConfigEndpointSuffix": ".azconfig.azure.cn",
3+
"azureAuthorityHost": "https://login.chinacloudapi.cn/",
4+
"cognitiveServicesEndpointSuffix": ".cognitiveservices.azure.cn",
5+
"containerRegistryEndpointSuffix": ".azurecr.cn",
6+
"cosmosEndpointSuffix": "cosmos.azure.cn",
7+
"enableStorageVersioning": false,
8+
"keyVaultDomainSuffix": ".vault.azure.cn",
9+
"keyVaultEndpointSuffix": ".vault.azure.cn",
10+
"keyVaultSku": "standard",
11+
"searchEndpointSuffix": "search.azure.cn",
12+
"serviceBusEndpointSuffix": ".servicebus.chinacloudapi.cn",
13+
"storageEndpointSuffix": "core.chinacloudapi.cn",
14+
"textAnalyticsSku": "S"
15+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"azureAuthorityHost": "https://login.microsoftonline.com/",
3+
"cognitiveServicesEndpointSuffix": ".cognitiveservices.azure.com",
4+
"communicationServicesEndpointSuffix": ".communication.azure.com",
5+
"keyVaultDomainSuffix": ".vault.azure.net",
6+
"keyVaultEndpointSuffix": ".vault.azure.net",
7+
"storageEndpointSuffix": "core.windows.net"
8+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"azConfigEndpointSuffix": ".azconfig.azure.us",
3+
"azureAuthorityHost": "https://login.microsoftonline.us/",
4+
"cognitiveServicesEndpointSuffix": ".cognitiveservices.azure.us",
5+
"containerRegistryEndpointSuffix": ".azurecr.us",
6+
"cosmosEndpointSuffix": "cosmos.azure.us",
7+
"enableStorageVersioning": false,
8+
"formRecognizerLocation": "usgovvirginia",
9+
"keyVaultDomainSuffix": ".vault.usgovcloudapi.net",
10+
"keyVaultEndpointSuffix": ".vault.usgovcloudapi.net",
11+
"keyVaultSku": "premium",
12+
"searchEndpointSuffix": "search.azure.us",
13+
"serviceBusEndpointSuffix": ".servicebus.usgovcloudapi.net",
14+
"storageEndpointSuffix": "core.usgovcloudapi.net"
15+
}

0 commit comments

Comments
 (0)