File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -19,9 +19,19 @@ function Get-CIPPAuthentication {
1919 }
2020 }
2121 } else {
22+ Write-Information ' Connecting to Azure'
2223 Connect-AzAccount - Identity
2324 $SubscriptionId = $env: WEBSITE_OWNER_NAME -split ' \+' | Select-Object - First 1
24- $null = Set-AzContext - SubscriptionId $SubscriptionId
25+ try {
26+ $Context = Get-AzContext
27+ if ($Context.Subscription.Id -ne $SubscriptionId ) {
28+ Write-Information " Setting context to subscription $SubscriptionId "
29+ $null = Set-AzContext - SubscriptionId $SubscriptionId
30+ }
31+ } catch {
32+ Write-Information " ERROR: Could not set context to subscription $SubscriptionId ."
33+ }
34+
2535 $keyvaultname = ($env: WEBSITE_DEPLOYMENT_ID -split ' -' )[0 ]
2636 $Variables | ForEach-Object {
2737 Set-Item - Path env:$_ - Value (Get-AzKeyVaultSecret - VaultName $keyvaultname - Name $_ - AsPlainText - ErrorAction Stop) - Force
You can’t perform that action at this time.
0 commit comments