33# # Desc: Install Azure CLI
44# ###############################################################################
55
6- Write-Host " Install the latest Azure CLI release"
7- $azCliUrl = " https://aka.ms/installazurecliwindowsx64"
8- Install-Binary - Url $azCliUrl - Name " azure-cli.msi"
6+ Write-Host ' Install the latest Azure CLI release'
7+
8+ $azureCliConfigPath = ' C:\azureCli'
9+ # Store azure-cli cache outside of the provisioning user's profile
10+ [Environment ]::SetEnvironmentVariable(' AZURE_CONFIG_DIR' , $azureCliConfigPath , [System.EnvironmentVariableTarget ]::Machine)
11+ # make variable to be available in the current session
12+ ${env: AZURE_CONFIG_DIR} = $azureCliConfigPath
13+
14+ $azCliUrl = ' https://aka.ms/installazurecliwindowsx64'
15+ Install-Binary - Url $azCliUrl - Name ' azure-cli.msi'
916
1017$azureCliExtensionPath = Join-Path $Env: CommonProgramFiles ' AzureCliExtensionDirectory'
11- $null = New-Item - ItemType " Directory" - Path $azureCliExtensionPath
18+ $null = New-Item - ItemType ' Directory' - Path $azureCliExtensionPath
19+
20+ [Environment ]::SetEnvironmentVariable(' AZURE_EXTENSION_DIR' , $azureCliExtensionPath , [System.EnvironmentVariableTarget ]::Machine)
21+ # make variable to be available in the current session
22+ ${env: AZURE_EXTENSION_DIR} = $azureCliExtensionPath
23+
24+ # Warm-up Azure CLI
25+
26+ Write-Host " Warmup 'az'"
1227
13- [Environment ]::SetEnvironmentVariable(" AZURE_EXTENSION_DIR" , $azureCliExtensionPath , [System.EnvironmentVariableTarget ]::Machine)
28+ $env: PATH = [Environment ]::GetEnvironmentVariable(' PATH' , ' Machine' )
29+ az -- help | Out-Null
30+ if ($LASTEXITCODE -ne 0 )
31+ {
32+ throw " Command 'az --help' failed"
33+ }
1434
15- Invoke-PesterTests - TestFile " CLI.Tools" - TestName " Azure CLI"
35+ Invoke-PesterTests - TestFile ' CLI.Tools' - TestName ' Azure CLI'
0 commit comments