diff --git a/Actions/AL-Go-Helper.ps1 b/Actions/AL-Go-Helper.ps1 index e6830e7f8..90ac29a2a 100644 --- a/Actions/AL-Go-Helper.ps1 +++ b/Actions/AL-Go-Helper.ps1 @@ -2410,7 +2410,7 @@ function ConnectAz { try { Clear-AzContext -Scope Process Clear-AzContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue - if ($azureCredentials.PSObject.Properties.Name -eq 'ClientSecret') { + if ($azureCredentials.PSObject.Properties.Name -eq 'ClientSecret' -and $azureCredentials.ClientSecret) { $credential = New-Object PSCredential -argumentList $azureCredentials.ClientId, $azureCredentials.ClientSecret Connect-AzAccount -ServicePrincipal -Tenant $azureCredentials.TenantId -Credential $credential -WarningAction SilentlyContinue | Out-Null } @@ -2424,7 +2424,7 @@ function ConnectAz { } Connect-AzAccount -ApplicationId $azureCredentials.ClientId -Tenant $azureCredentials.TenantId -FederatedToken $result.value -WarningAction SilentlyContinue | Out-Null } - if ($azureCredentials.PSObject.Properties.Name -eq 'SubScriptionId') { + if ($azureCredentials.PSObject.Properties.Name -eq 'SubScriptionId' -and $azureCredentials.subscriptionId) { Set-AzContext -SubscriptionId $azureCredentials.SubscriptionId -Tenant $azureCredentials.TenantId -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Out-Null } $script:keyvaultConnectionExists = $true diff --git a/Actions/ReadSecrets/ReadSecretsHelper.psm1 b/Actions/ReadSecrets/ReadSecretsHelper.psm1 index e4436dde6..08547b042 100644 --- a/Actions/ReadSecrets/ReadSecretsHelper.psm1 +++ b/Actions/ReadSecrets/ReadSecretsHelper.psm1 @@ -139,11 +139,11 @@ function GetKeyVaultSecret { Get-AzKeyVaultSecret -VaultName $keyVaultCredentials.keyVaultName | ForEach-Object { $_.Name } | Out-Null } catch { - if ($keyVaultCredentials.PSObject.Properties.Name -eq 'ClientAssertion') { - $message = "Error trying to get secrets from Azure Key Vault, maybe your Key Vault isn't setup for role based access control?. Error was $($_.Exception.Message)" + if ($keyVaultCredentials.PSObject.Properties.Name -eq 'ClientSecret') { + $message = "Error trying to get secrets from Azure Key Vault. Error was $($_.Exception.Message)" } else { - $message = "Error trying to get secrets from Azure Key Vault. Error was $($_.Exception.Message)" + $message = "Error trying to get secrets from Azure Key Vault, maybe your Key Vault isn't setup for role based access control?. Error was $($_.Exception.Message)" } } }