File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
Modules/CIPPCore/Public/Entrypoints Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -21,8 +21,24 @@ Function Invoke-ExecListAppId {
21
21
$env: ApplicationID = $Secret.ApplicationID
22
22
$env: TenantID = $Secret.TenantID
23
23
} else {
24
- $env: ApplicationID = (Get-AzKeyVaultSecret - AsPlainText - VaultName $env: WEBSITE_DEPLOYMENT_ID - Name ' ApplicationID' ).SecretValueText
25
- $env: TenantID = (Get-AzKeyVaultSecret - AsPlainText - VaultName $env: WEBSITE_DEPLOYMENT_ID - Name ' TenantID' ).SecretValueText
24
+ Write-Information ' Connecting to Azure'
25
+ Connect-AzAccount - Identity
26
+ $SubscriptionId = $env: WEBSITE_OWNER_NAME -split ' \+' | Select-Object - First 1
27
+ try {
28
+ $Context = Get-AzContext
29
+ if ($Context.Subscription ) {
30
+ # Write-Information "Current context: $($Context | ConvertTo-Json)"
31
+ if ($Context.Subscription.Id -ne $SubscriptionId ) {
32
+ Write-Information " Setting context to subscription $SubscriptionId "
33
+ $null = Set-AzContext - SubscriptionId $SubscriptionId
34
+ }
35
+ }
36
+ } catch {
37
+ Write-Information " ERROR: Could not set context to subscription $SubscriptionId ."
38
+ }
39
+ $keyvaultname = ($env: WEBSITE_DEPLOYMENT_ID -split ' -' )[0 ]
40
+ $env: ApplicationID = (Get-AzKeyVaultSecret - AsPlainText - VaultName $keyvaultname - Name ' ApplicationID' ).SecretValueText
41
+ $env: TenantID = (Get-AzKeyVaultSecret - AsPlainText - VaultName $keyvaultname - Name ' TenantID' ).SecretValueText
26
42
}
27
43
$Results = @ {
28
44
applicationId = $env: ApplicationID
You can’t perform that action at this time.
0 commit comments