Skip to content

Commit 8266d44

Browse files
[windows] warmup Azure CLI
Improve Azure CLI first run timing. Follow up: actions#8294 Co-authored-by: Jesse Houwing <jesse.houwing@gmail.com>
1 parent b3852fe commit 8266d44

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

images/win/scripts/Installers/Install-AzureCli.ps1

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,30 @@
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

Comments
 (0)