Add AZURE_SERVICE_DIRECTORY environment variable in test deployment script (#3373)
Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
This commit is contained in:
parent
66b9e75010
commit
e077374ea5
@ -236,7 +236,8 @@ function BuildBicepFile([System.IO.FileSystemInfo] $file)
|
||||
return $templateFilePath
|
||||
}
|
||||
|
||||
function BuildDeploymentOutputs([string]$serviceDirectoryPrefix, [object]$azContext, [object]$deployment) {
|
||||
function BuildDeploymentOutputs([string]$serviceName, [object]$azContext, [object]$deployment) {
|
||||
$serviceDirectoryPrefix = BuildServiceDirectoryPrefix $serviceName
|
||||
# Add default values
|
||||
$deploymentOutputs = [Ordered]@{
|
||||
"${serviceDirectoryPrefix}CLIENT_ID" = $TestApplicationId;
|
||||
@ -249,6 +250,7 @@ function BuildDeploymentOutputs([string]$serviceDirectoryPrefix, [object]$azCont
|
||||
"${serviceDirectoryPrefix}AZURE_AUTHORITY_HOST" = $azContext.Environment.ActiveDirectoryAuthority;
|
||||
"${serviceDirectoryPrefix}RESOURCE_MANAGER_URL" = $azContext.Environment.ResourceManagerUrl;
|
||||
"${serviceDirectoryPrefix}SERVICE_MANAGEMENT_URL" = $azContext.Environment.ServiceManagementUrl;
|
||||
"AZURE_SERVICE_DIRECTORY" = $serviceName.ToUpperInvariant();
|
||||
}
|
||||
|
||||
MergeHashes $EnvironmentVariables $(Get-Variable deploymentOutputs)
|
||||
@ -268,8 +270,7 @@ function BuildDeploymentOutputs([string]$serviceDirectoryPrefix, [object]$azCont
|
||||
}
|
||||
|
||||
function SetDeploymentOutputs([string]$serviceName, [object]$azContext, [object]$deployment, [object]$templateFile) {
|
||||
$serviceDirectoryPrefix = $serviceName.ToUpperInvariant() + "_"
|
||||
$deploymentOutputs = BuildDeploymentOutputs $serviceDirectoryPrefix $azContext $deployment
|
||||
$deploymentOutputs = BuildDeploymentOutputs $serviceName $azContext $deployment
|
||||
|
||||
if ($OutFile) {
|
||||
if (!$IsWindows) {
|
||||
@ -300,7 +301,7 @@ function SetDeploymentOutputs([string]$serviceName, [object]$azContext, [object]
|
||||
$EnvironmentVariables[$key] = $value
|
||||
|
||||
if ($CI) {
|
||||
if (ShouldMarkValueAsSecret $serviceDirectoryPrefix $key $value $notSecretValues) {
|
||||
if (ShouldMarkValueAsSecret $serviceName $key $value $notSecretValues) {
|
||||
# Treat all ARM template output variables as secrets since "SecureString" variables do not set values.
|
||||
# In order to mask secrets but set environment variables for any given ARM template, we set variables twice as shown below.
|
||||
LogVsoCommand "##vso[task.setvariable variable=_$key;issecret=true;]$value"
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
function ShouldMarkValueAsSecret([string]$serviceDirectoryPrefix, [string]$key, [string]$value, [array]$allowedValues = @())
|
||||
function BuildServiceDirectoryPrefix([string]$serviceName) {
|
||||
return $serviceName.ToUpperInvariant() + "_"
|
||||
}
|
||||
|
||||
function ShouldMarkValueAsSecret([string]$serviceName, [string]$key, [string]$value, [array]$allowedValues = @())
|
||||
{
|
||||
$logOutputNonSecret = @(
|
||||
# Environment Variables
|
||||
@ -14,6 +18,7 @@ function ShouldMarkValueAsSecret([string]$serviceDirectoryPrefix, [string]$key,
|
||||
"RESOURCE_MANAGER_URL",
|
||||
"SERVICE_MANAGEMENT_URL",
|
||||
"ENDPOINT_SUFFIX",
|
||||
"SERVICE_DIRECTORY",
|
||||
# This is used in many places and is harder to extract from the base subscription config, so hardcode it for now.
|
||||
"STORAGE_ENDPOINT_SUFFIX",
|
||||
# Parameters
|
||||
@ -25,6 +30,8 @@ function ShouldMarkValueAsSecret([string]$serviceDirectoryPrefix, [string]$key,
|
||||
"ProvisionerApplicationId"
|
||||
)
|
||||
|
||||
$serviceDirectoryPrefix = BuildServiceDirectoryPrefix $serviceName
|
||||
|
||||
$suffix1 = $key -replace $serviceDirectoryPrefix, ""
|
||||
$suffix2 = $key -replace "AZURE_", ""
|
||||
$variants = @($key, $suffix1, $suffix2)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user