Skip to content

Commit ffe7e6a

Browse files
Implemented az-cli warmup (#11173)
1 parent 19e81a0 commit ffe7e6a

File tree

3 files changed

+37
-10
lines changed

3 files changed

+37
-10
lines changed

images/ubuntu/scripts/build/cleanup.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ if command -v journalctl; then
1919
journalctl --vacuum-time=1s
2020
fi
2121

22+
# remove redundant folders from azcli
23+
if [[ -z "${AZURE_CONFIG_DIR}" ]]; then
24+
rm -rf $AZURE_CONFIG_DIR/logs
25+
rm -rf $AZURE_CONFIG_DIR/commands
26+
rm -rf $AZURE_CONFIG_DIR/telemetry
27+
fi
28+
2229
# delete all .gz and rotated file
2330
find /var/log -type f -regex ".*\.gz$" -delete
2431
find /var/log -type f -regex ".*\.[0-9]$" -delete

images/ubuntu/scripts/build/install-azure-cli.sh

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,40 @@
44
## Desc: Install Azure CLI (az)
55
################################################################################
66

7+
# Source the helpers for use with the script
8+
source $HELPER_SCRIPTS/etc-environment.sh
9+
10+
# AZURE_CONFIG_DIR shell variable defines where the CLI configuration file for managing behavior are stored
11+
# https://learn.microsoft.com/en-us/cli/azure/azure-cli-configuration#cli-configuration-file
12+
# This path SHOULD be different from the installation directory /opt/az/
13+
export AZURE_CONFIG_DIR="/opt/az-config"
14+
mkdir -p $AZURE_CONFIG_DIR
15+
set_etc_environment_variable "AZURE_CONFIG_DIR" "${AZURE_CONFIG_DIR}"
16+
17+
# AZURE_EXTENSION_DIR shell variable defines where modules are installed
18+
# https://docs.microsoft.com/en-us/cli/azure/azure-cli-extensions-overview
19+
# This path SHOULD be different from the installation directory /opt/az/
20+
export AZURE_EXTENSION_DIR="/opt/az-extension"
21+
mkdir -p $AZURE_EXTENSION_DIR
22+
set_etc_environment_variable "AZURE_EXTENSION_DIR" "${AZURE_EXTENSION_DIR}"
23+
724
# Install Azure CLI (instructions taken from https://docs.microsoft.com/en-us/cli/azure/install-azure-cli)
825
curl -fsSL https://aka.ms/InstallAzureCLIDeb | sudo bash
926

1027
echo "azure-cli https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=apt" >> $HELPER_SCRIPTS/apt-sources.txt
1128

12-
rm -f /etc/apt/sources.list.d/azure-cli.list
13-
rm -f /etc/apt/sources.list.d/azure-cli.list.save
29+
# Remove Azure CLI repository (instructions taken from https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=apt#uninstall-azure-cli)
30+
rm -f /etc/apt/sources.list.d/azure-cli.sources
31+
32+
echo "Warmup 'az'"
33+
az --help > /dev/null
34+
if [ $? -ne 0 ]; then
35+
echo "Command 'az --help' failed"
36+
exit 1
37+
fi
38+
39+
# Hand over the ownership of the directories and files to the non-root user
40+
chown -R "$SUDO_USER:$SUDO_USER" $AZURE_CONFIG_DIR
41+
chown -R "$SUDO_USER:$SUDO_USER" $AZURE_EXTENSION_DIR
1442

1543
invoke_tests "CLI.Tools" "Azure CLI"

images/ubuntu/scripts/build/install-azure-devops-cli.sh

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@
44
## Desc: Install Azure DevOps CLI (az devops)
55
################################################################################
66

7-
# Source the helpers for use with the script
8-
source $HELPER_SCRIPTS/etc-environment.sh
9-
10-
# AZURE_EXTENSION_DIR shell variable defines where modules are installed
11-
# https://docs.microsoft.com/en-us/cli/azure/azure-cli-extensions-overview
12-
export AZURE_EXTENSION_DIR=/opt/az/azcliextensions
13-
set_etc_environment_variable "AZURE_EXTENSION_DIR" "${AZURE_EXTENSION_DIR}"
14-
157
# install azure devops Cli extension
168
az extension add -n azure-devops
179

0 commit comments

Comments
 (0)