Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set login experience if using CLI version 2.61.0 #184

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion tools/scripts/AksEdgeAzureSetup/AksEdgeAzureSetup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Param(
[switch]$spCredReset
)


#Requires -RunAsAdministrator
New-Variable -Name gAksEdgeAzureSetup -Value "1.0.230829.1100" -Option Constant -ErrorAction SilentlyContinue
New-Variable -Option Constant -ErrorAction SilentlyContinue -Name cliMinVersions -Value @{
Expand All @@ -19,10 +20,22 @@ New-Variable -Option Constant -ErrorAction SilentlyContinue -Name arcLocations -
"westus", "northcentralus", "koreacentral", "japaneast", "eastasia", "westus3",
"canadacentral", "eastus2euap"
)

function Set-CLILoginExperience
{
$currVersion = ((az version -o json) | ConvertFrom-Json).'azure-cli'
if($currVersion -eq '2.61.0')
{
Write-Host "Warning: Az CLI version 2.61.0 has known issues. Reverting to the previous browser-based authentication method." -ForegroundColor Yellow
az config set core.enable_broker_on_windows=false
az config set core.login_experience_v2=off
}
}

function Test-AzVersions {
#Function to check if the installed az versions are greater or equal to minVersions
$retval = $true
$curVersion = (az version) | ConvertFrom-Json
$curVersion = (az version -o json) | ConvertFrom-Json
if (-not $curVersion) { return $false }
foreach ($item in $cliMinVersions.Keys ) {
Write-Host " Checking $item minVersion $($cliMinVersions.$item).." -NoNewline
Expand Down Expand Up @@ -65,6 +78,9 @@ function Install-AzCli {
Write-Host "Error: Required versions not found after az upgrade. Please try uninstalling and reinstalling" -ForegroundColor Red
}
}

# workaround CLI login issue if using CLI 2.61.0
Set-CLILoginExperience
}
# Formats JSON in a nicer format than the built-in ConvertTo-Json does.
# https://github.com/PowerShell/PowerShell/issues/2736
Expand Down