From f42d548eb77a94fd18af537bacef6a001d1f30b5 Mon Sep 17 00:00:00 2001 From: Lars Nielsen Date: Thu, 12 Dec 2024 12:40:49 +0100 Subject: [PATCH] Implemented az-cli warmup --- images/ubuntu/scripts/build/cleanup.sh | 5 +++++ .../ubuntu/scripts/build/install-azure-cli.sh | 22 +++++++++++++++++++ .../scripts/build/install-azure-devops-cli.sh | 8 ------- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/images/ubuntu/scripts/build/cleanup.sh b/images/ubuntu/scripts/build/cleanup.sh index 17c7ccc3f6fa..f8c410990553 100644 --- a/images/ubuntu/scripts/build/cleanup.sh +++ b/images/ubuntu/scripts/build/cleanup.sh @@ -19,6 +19,11 @@ if command -v journalctl; then journalctl --vacuum-time=1s fi +# remove redundant folders from azcli +rm -rf $AZURE_CONFIG_DIR/logs +rm -rf $AZURE_CONFIG_DIR/commands +rm -rf $AZURE_CONFIG_DIR/telemetry + # delete all .gz and rotated file find /var/log -type f -regex ".*\.gz$" -delete find /var/log -type f -regex ".*\.[0-9]$" -delete diff --git a/images/ubuntu/scripts/build/install-azure-cli.sh b/images/ubuntu/scripts/build/install-azure-cli.sh index 0004f7bdef63..89afad4f4039 100644 --- a/images/ubuntu/scripts/build/install-azure-cli.sh +++ b/images/ubuntu/scripts/build/install-azure-cli.sh @@ -4,6 +4,21 @@ ## Desc: Install Azure CLI (az) ################################################################################ +# Source the helpers for use with the script +source $HELPER_SCRIPTS/etc-environment.sh + +# AZURE_CONFIG_DIR shell variable defines where the CLI configuration file for managing behavior are stored +# https://learn.microsoft.com/en-us/cli/azure/azure-cli-configuration#cli-configuration-file +# This path SHOULD be different from the installation directory /opt/az/ +export AZURE_CONFIG_DIR="/opt/az-config" +set_etc_environment_variable "AZURE_CONFIG_DIR" "${AZURE_CONFIG_DIR}" + +# AZURE_EXTENSION_DIR shell variable defines where modules are installed +# https://docs.microsoft.com/en-us/cli/azure/azure-cli-extensions-overview +# This path SHOULD be different from the installation directory /opt/az/ +export AZURE_EXTENSION_DIR="/opt/az-extension" +set_etc_environment_variable "AZURE_EXTENSION_DIR" "${AZURE_EXTENSION_DIR}" + # Install Azure CLI (instructions taken from https://docs.microsoft.com/en-us/cli/azure/install-azure-cli) curl -fsSL https://aka.ms/InstallAzureCLIDeb | sudo bash @@ -12,4 +27,11 @@ echo "azure-cli https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-lin rm -f /etc/apt/sources.list.d/azure-cli.list rm -f /etc/apt/sources.list.d/azure-cli.list.save +echo "Warmup 'az'" +az --help > /dev/null +if [ $? -ne 0 ]; then + echo "Command 'az --help' failed" + exit 1 +fi + invoke_tests "CLI.Tools" "Azure CLI" diff --git a/images/ubuntu/scripts/build/install-azure-devops-cli.sh b/images/ubuntu/scripts/build/install-azure-devops-cli.sh index 81948ac95440..98e1318a9148 100644 --- a/images/ubuntu/scripts/build/install-azure-devops-cli.sh +++ b/images/ubuntu/scripts/build/install-azure-devops-cli.sh @@ -4,14 +4,6 @@ ## Desc: Install Azure DevOps CLI (az devops) ################################################################################ -# Source the helpers for use with the script -source $HELPER_SCRIPTS/etc-environment.sh - -# AZURE_EXTENSION_DIR shell variable defines where modules are installed -# https://docs.microsoft.com/en-us/cli/azure/azure-cli-extensions-overview -export AZURE_EXTENSION_DIR=/opt/az/azcliextensions -set_etc_environment_variable "AZURE_EXTENSION_DIR" "${AZURE_EXTENSION_DIR}" - # install azure devops Cli extension az extension add -n azure-devops