2019-12-13 09:48:00 -05:00
|
|
|
################################################################################
|
|
|
|
|
## File: Install-AzureCli.ps1
|
|
|
|
|
## Desc: Install Azure CLI
|
|
|
|
|
################################################################################
|
|
|
|
|
|
2023-10-05 15:03:58 +02:00
|
|
|
Write-Host 'Install the latest Azure CLI release'
|
|
|
|
|
|
|
|
|
|
$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
|
|
|
|
|
|
2023-10-13 14:35:56 +02:00
|
|
|
$azCliUrl = 'https://aka.ms/installazurecliwindowsx64'
|
2023-10-11 11:02:59 +02:00
|
|
|
$azCliSignatureThumbprint = "72105B6D5F370B62FD5C82F1512F7AD7DEE5F2C0"
|
|
|
|
|
Install-Binary -Url $azCliUrl -Name 'azure-cli.msi' -ExpectedSignature $azCliSignatureThumbprint
|
2019-12-13 09:48:00 -05:00
|
|
|
|
2021-03-26 18:21:42 +03:00
|
|
|
$azureCliExtensionPath = Join-Path $Env:CommonProgramFiles 'AzureCliExtensionDirectory'
|
2023-10-05 15:03:58 +02:00
|
|
|
$null = New-Item -ItemType 'Directory' -Path $azureCliExtensionPath
|
2019-12-13 09:48:00 -05:00
|
|
|
|
2023-10-05 15:03:58 +02:00
|
|
|
[Environment]::SetEnvironmentVariable('AZURE_EXTENSION_DIR', $azureCliExtensionPath, [System.EnvironmentVariableTarget]::Machine)
|
|
|
|
|
# make variable to be available in the current session
|
|
|
|
|
${env:AZURE_EXTENSION_DIR} = $azureCliExtensionPath
|
2020-07-07 13:20:09 +03:00
|
|
|
|
2023-10-05 15:03:58 +02:00
|
|
|
# Warm-up Azure CLI
|
|
|
|
|
|
|
|
|
|
Write-Host "Warmup 'az'"
|
|
|
|
|
|
|
|
|
|
$env:PATH = [Environment]::GetEnvironmentVariable('PATH', 'Machine')
|
|
|
|
|
az --help | Out-Null
|
2023-10-06 11:54:51 +02:00
|
|
|
if ($LASTEXITCODE -ne 0) {
|
2023-10-05 15:03:58 +02:00
|
|
|
throw "Command 'az --help' failed"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Invoke-PesterTests -TestFile 'CLI.Tools' -TestName 'Azure CLI'
|