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+
22+ # Warm-up Azure CLI
23+
24+ Write-Host " Warmup 'az'"
1225
13- [Environment ]::SetEnvironmentVariable(" AZURE_EXTENSION_DIR" , $azureCliExtensionPath , [System.EnvironmentVariableTarget ]::Machine)
26+ az -- help
27+ if ($LASTEXITCODE -ne 0 )
28+ {
29+ throw " Command 'az --help' failed"
30+ }
1431
15- Invoke-PesterTests - TestFile " CLI.Tools" - TestName " Azure CLI"
32+ Invoke-PesterTests - TestFile ' CLI.Tools' - TestName ' Azure CLI'
0 commit comments