[windows] warmup Azure CLI (#8427)
* [windows] warmup Azure CLI Improve Azure CLI first run timing. Follow up: https://github.com/actions/runner-images/pull/8294 Co-authored-by: Jesse Houwing <[email protected]> * expose AZURE_EXTENSION_DIR to image generation * suppress az warmup output * refresh PATH before warmup --------- Co-authored-by: Jesse Houwing <[email protected]>
This commit is contained in:
co-authored by
Jesse Houwing
parent
fbaf4c67c6
commit
0795b9ed8b
@@ -3,13 +3,33 @@
|
|||||||
## Desc: Install Azure CLI
|
## Desc: Install Azure CLI
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
Write-Host "Install the latest Azure CLI release"
|
Write-Host 'Install the latest Azure CLI release'
|
||||||
$azCliUrl = "https://aka.ms/installazurecliwindowsx64"
|
|
||||||
Install-Binary -Url $azCliUrl -Name "azure-cli.msi"
|
$azureCliConfigPath = 'C:\azureCli'
|
||||||
|
# Store azure-cli cache outside of the provisioning user's profile
|
||||||
|
[Environment]::SetEnvironmentVariable('AZURE_CONFIG_DIR', $azureCliConfigPath, [System.EnvironmentVariableTarget]::Machine)
|
||||||
|
# make variable to be available in the current session
|
||||||
|
${env:AZURE_CONFIG_DIR} = $azureCliConfigPath
|
||||||
|
|
||||||
|
$azCliUrl = 'https://aka.ms/installazurecliwindowsx64'
|
||||||
|
Install-Binary -Url $azCliUrl -Name 'azure-cli.msi'
|
||||||
|
|
||||||
$azureCliExtensionPath = Join-Path $Env:CommonProgramFiles 'AzureCliExtensionDirectory'
|
$azureCliExtensionPath = Join-Path $Env:CommonProgramFiles 'AzureCliExtensionDirectory'
|
||||||
$null = New-Item -ItemType "Directory" -Path $azureCliExtensionPath
|
$null = New-Item -ItemType 'Directory' -Path $azureCliExtensionPath
|
||||||
|
|
||||||
[Environment]::SetEnvironmentVariable("AZURE_EXTENSION_DIR", $azureCliExtensionPath, [System.EnvironmentVariableTarget]::Machine)
|
[Environment]::SetEnvironmentVariable('AZURE_EXTENSION_DIR', $azureCliExtensionPath, [System.EnvironmentVariableTarget]::Machine)
|
||||||
|
# make variable to be available in the current session
|
||||||
|
${env:AZURE_EXTENSION_DIR} = $azureCliExtensionPath
|
||||||
|
|
||||||
Invoke-PesterTests -TestFile "CLI.Tools" -TestName "Azure CLI"
|
# Warm-up Azure CLI
|
||||||
|
|
||||||
|
Write-Host "Warmup 'az'"
|
||||||
|
|
||||||
|
$env:PATH = [Environment]::GetEnvironmentVariable('PATH', 'Machine')
|
||||||
|
az --help | Out-Null
|
||||||
|
if ($LASTEXITCODE -ne 0)
|
||||||
|
{
|
||||||
|
throw "Command 'az --help' failed"
|
||||||
|
}
|
||||||
|
|
||||||
|
Invoke-PesterTests -TestFile 'CLI.Tools' -TestName 'Azure CLI'
|
||||||
|
|||||||
Reference in New Issue
Block a user