|
4 | 4 | ## Desc: Install Azure CLI (az) |
5 | 5 | ################################################################################ |
6 | 6 |
|
| 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 | + |
7 | 24 | # Install Azure CLI (instructions taken from https://docs.microsoft.com/en-us/cli/azure/install-azure-cli) |
8 | 25 | curl -fsSL https://aka.ms/InstallAzureCLIDeb | sudo bash |
9 | 26 |
|
10 | 27 | echo "azure-cli https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=apt" >> $HELPER_SCRIPTS/apt-sources.txt |
11 | 28 |
|
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 |
14 | 42 |
|
15 | 43 | invoke_tests "CLI.Tools" "Azure CLI" |
0 commit comments