Skip to content

Commit 2053d01

Browse files
committed
Fix env far references
1 parent 5d57810 commit 2053d01

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

azd-hooks/scripts/hooks/postprovision/deploy_power_platform_solution.ps1

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,6 @@ if (!(Test-Path $SettingsDirectory)) {
7070
New-Item -ItemType Directory -Path $SettingsDirectory -Force | Out-Null
7171
}
7272

73-
# Copy azd .env values to local state
74-
$envValues = azd env get-values
75-
foreach ($line in $envValues) {
76-
if ($line -match '(.+)=(.+)') {
77-
$key = $matches[1]
78-
$value = $matches[2] -replace '^"' -replace '"$'
79-
Set-Item -Path "env:$key" -Value $value
80-
}
81-
}
82-
83-
8473
Write-Host "INFO: Starting Power Platform solution deployment"
8574

8675
# Function to ensure PAC CLI is installed
@@ -113,28 +102,28 @@ function Set-PacAuthentication {
113102

114103
try { # Try GitHub federated auth first if explicitly requested and environment variables are available
115104
if ($UseGithubFederated -and
116-
(![string]::IsNullOrEmpty($env:POWER_PLATFORM_CLIENT_ID) -and
117-
![string]::IsNullOrEmpty($env:POWER_PLATFORM_TENANT_ID))) {
105+
(![string]::IsNullOrEmpty($POWER_PLATFORM_CLIENT_ID) -and
106+
![string]::IsNullOrEmpty($POWER_PLATFORM_TENANT_ID))) {
118107
Write-Host "INFO: Setting a PAC auth profile based on GitHub federated authentication"
119108
$authOutput = & pac auth create --name github-federated-auth `
120-
--applicationId $env:POWER_PLATFORM_CLIENT_ID `
121-
--tenant $env:POWER_PLATFORM_TENANT_ID `
109+
--applicationId $POWER_PLATFORM_CLIENT_ID `
110+
--tenant $POWER_PLATFORM_TENANT_ID `
122111
--githubFederated
123112
& pac auth select --name github-federated-auth
124113
}
125114
# Try Service Principal auth second
126-
elseif (![string]::IsNullOrEmpty($env:POWER_PLATFORM_CLIENT_ID) -and
127-
![string]::IsNullOrEmpty($env:POWER_PLATFORM_CLIENT_SECRET) -and
128-
![string]::IsNullOrEmpty($env:POWER_PLATFORM_TENANT_ID)) {
115+
elseif (![string]::IsNullOrEmpty($POWER_PLATFORM_CLIENT_ID) -and
116+
![string]::IsNullOrEmpty($POWER_PLATFORM_CLIENT_SECRET) -and
117+
![string]::IsNullOrEmpty($POWER_PLATFORM_TENANT_ID)) {
129118

130119
Write-Host "INFO: Found service principal environment variables, using service principal authentication"
131120

132121
# Execute the auth create command and capture output
133122
# TODO decide whether it's worth reconfiguring the devcontainer to support keyring auth so we can remove the cleartext-caching parameter below
134123
$authOutput = & pac auth create --name service-principal-auth `
135-
--applicationId $env:POWER_PLATFORM_CLIENT_ID `
136-
--clientSecret $env:POWER_PLATFORM_CLIENT_SECRET `
137-
--tenant $env:POWER_PLATFORM_TENANT_ID `
124+
--applicationId $POWER_PLATFORM_CLIENT_ID `
125+
--clientSecret $POWER_PLATFORM_CLIENT_SECRET `
126+
--tenant $POWER_PLATFORM_TENANT_ID `
138127
--accept-cleartext-caching 2>&1 | Out-String
139128

140129
# Log that authentication was attempted (don't log the actual output which may contain secrets)

0 commit comments

Comments
 (0)