File tree Expand file tree Collapse file tree 9 files changed +24
-5
lines changed
HTTP Functions/CIPP/Setup Expand file tree Collapse file tree 9 files changed +24
-5
lines changed Original file line number Diff line number Diff line change 11function Set-CippApiAuth {
22 [CmdletBinding (SupportsShouldProcess )]
3- Param (
3+ param (
44 [string ]$RGName ,
55 [string ]$FunctionAppName ,
66 [string ]$TenantId ,
@@ -9,7 +9,9 @@ function Set-CippApiAuth {
99
1010 if ($env: MSI_SECRET ) {
1111 Disable-AzContextAutosave - Scope Process | Out-Null
12- $Context = (Connect-AzAccount - Identity).Context
12+ $null = Connect-AzAccount - Identity
13+ $SubscriptionId = $ENV: WEBSITE_OWNER_NAME -split ' +' | Select-Object - First 1
14+ $Context = Set-AzContext - SubscriptionId $SubscriptionId
1315 } else {
1416 $Context = Get-AzContext
1517 }
Original file line number Diff line number Diff line change @@ -51,7 +51,9 @@ Function Invoke-ExecSAMSetup {
5151 } else {
5252 if ($env: MSI_SECRET ) {
5353 Disable-AzContextAutosave - Scope Process | Out-Null
54- $AzSession = Connect-AzAccount - Identity
54+ $null = Connect-AzAccount - Identity
55+ $SubscriptionId = $ENV: WEBSITE_OWNER_NAME -split ' +' | Select-Object - First 1
56+ $null = Set-AzContext - SubscriptionId $SubscriptionId
5557 }
5658 }
5759 if (! $ENV: SetFromProfile ) {
Original file line number Diff line number Diff line change @@ -25,7 +25,9 @@ function Start-UpdateTokensTimer {
2525 } else {
2626 if ($env: MSI_SECRET ) {
2727 Disable-AzContextAutosave - Scope Process | Out-Null
28- $AzSession = Connect-AzAccount - Identity
28+ $null = Connect-AzAccount - Identity
29+ $SubscriptionId = $ENV: WEBSITE_OWNER_NAME -split ' +' | Select-Object - First 1
30+ $null = Set-AzContext - SubscriptionId $SubscriptionId
2931 }
3032 $KV = ($ENV: WEBSITE_DEPLOYMENT_ID -split ' -' )[0 ]
3133 if ($Refreshtoken ) {
Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ function Get-CIPPAuthentication {
2020 }
2121 } else {
2222 Connect-AzAccount - Identity
23+ $SubscriptionId = $ENV: WEBSITE_OWNER_NAME -split ' +' | Select-Object - First 1
24+ $null = Set-AzContext - SubscriptionId $SubscriptionId
2325 $keyvaultname = ($ENV: WEBSITE_DEPLOYMENT_ID -split ' -' )[0 ]
2426 $Variables | ForEach-Object {
2527 Set-Item - Path ENV:$_ - Value (Get-AzKeyVaultSecret - VaultName $keyvaultname - Name $_ - AsPlainText - ErrorAction Stop) - Force
Original file line number Diff line number Diff line change @@ -34,7 +34,9 @@ function Test-CIPPAccessPermissions {
3434 if ($env: MSI_SECRET ) {
3535 try {
3636 Disable-AzContextAutosave - Scope Process | Out-Null
37- $AzSession = Connect-AzAccount - Identity
37+ $null = Connect-AzAccount - Identity
38+ $SubscriptionId = $ENV: WEBSITE_OWNER_NAME -split ' +' | Select-Object - First 1
39+ $null = Set-AzContext - SubscriptionId $SubscriptionId
3840
3941 $KV = $ENV: WEBSITE_DEPLOYMENT_ID
4042 $KeyVaultRefresh = Get-AzKeyVaultSecret - VaultName $kv - Name ' RefreshToken' - AsPlainText
Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ function Get-ExtensionAPIKey {
2222 } else {
2323 $keyvaultname = ($ENV: WEBSITE_DEPLOYMENT_ID -split ' -' )[0 ]
2424 $null = Connect-AzAccount - Identity
25+ $SubscriptionId = $ENV: WEBSITE_OWNER_NAME -split ' +' | Select-Object - First 1
26+ $null = Set-AzContext - SubscriptionId $SubscriptionId
2527 $APIKey = (Get-AzKeyVaultSecret - VaultName $keyvaultname - Name $Extension - AsPlainText)
2628 }
2729 Set-Item - Path " ENV:$Var " - Value $APIKey - Force - ErrorAction SilentlyContinue
Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ function Set-ExtensionAPIKey {
2525 } else {
2626 $keyvaultname = ($ENV: WEBSITE_DEPLOYMENT_ID -split ' -' )[0 ]
2727 $null = Connect-AzAccount - Identity
28+ $SubscriptionId = $ENV: WEBSITE_OWNER_NAME -split ' +' | Select-Object - First 1
29+ $null = Set-AzContext - SubscriptionId $SubscriptionId
2830 $null = Set-AzKeyVaultSecret - VaultName $keyvaultname - Name $Extension - SecretValue (ConvertTo-SecureString - AsPlainText - Force - String $APIKey )
2931 }
3032 Set-Item - Path " ENV:$Var " - Value $APIKey - Force - ErrorAction SilentlyContinue
Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ function Get-GradientToken {
44 )
55 if ($Configuration.vendorKey ) {
66 $null = Connect-AzAccount - Identity
7+ $SubscriptionId = $ENV: WEBSITE_OWNER_NAME -split ' +' | Select-Object - First 1
8+ $null = Set-AzContext - SubscriptionId $SubscriptionId
79 $keyvaultname = ($ENV: WEBSITE_DEPLOYMENT_ID -split ' -' )[0 ]
810 $partnerApiKey = (Get-AzKeyVaultSecret - VaultName $keyvaultname - Name ' Gradient' - AsPlainText)
911 $authorizationToken = [Convert ]::ToBase64String([Text.Encoding ]::UTF8.GetBytes(" $ ( $configuration.vendorKey ) :$ ( $partnerApiKey ) " ))
Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ function Get-HIBPAuth {
99 $Secret = (Get-CIPPAzDataTableEntity @DevSecretsTable - Filter " PartitionKey eq 'HIBP' and RowKey eq 'HIBP'" ).APIKey
1010 } else {
1111 $null = Connect-AzAccount - Identity
12+ $SubscriptionId = $ENV: WEBSITE_OWNER_NAME -split ' +' | Select-Object - First 1
13+ $null = Set-AzContext - SubscriptionId $SubscriptionId
14+
1215 $VaultName = ($ENV: WEBSITE_DEPLOYMENT_ID -split ' -' )[0 ]
1316 try {
1417 $Secret = Get-AzKeyVaultSecret - VaultName $VaultName - Name ' HIBP' - AsPlainText - ErrorAction Stop
You can’t perform that action at this time.
0 commit comments