Skip to content

Commit

Permalink
Use Azure STORAGE_ACCOUNT_NAME env if set during init-vhd
Browse files Browse the repository at this point in the history
  • Loading branch information
kkeshavamurthy committed May 5, 2021
1 parent c64f5ff commit 196302c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions images/capi/packer/azure/scripts/init-vhd.sh
Expand Up @@ -5,7 +5,7 @@
echo "Sign into Azure"
tracestate="$(shopt -po xtrace)"
set +o xtrace
az login --service-principal -u ${AZURE_CLIENT_ID} -p ${AZURE_CLIENT_SECRET} --tenant ${AZURE_TENANT_ID} >/dev/null 2>&1
az login --service-principal -u ${AZURE_CLIENT_ID} -p ${AZURE_CLIENT_SECRET} --tenant ${AZURE_TENANT_ID} >/dev/null 2>&1
az account set -s ${AZURE_SUBSCRIPTION_ID} >/dev/null 2>&1
eval "$tracestate"

Expand All @@ -15,7 +15,7 @@ export AZURE_LOCATION="${AZURE_LOCATION:-southcentralus}"
az group create -n ${RESOURCE_GROUP_NAME} -l ${AZURE_LOCATION} --tags ${TAGS:-}
CREATE_TIME="$(date +%s)"
RANDOM_SUFFIX="$(head /dev/urandom | LC_ALL=C tr -dc a-z | head -c 4 ; echo '')"
export STORAGE_ACCOUNT_NAME="capi${CREATE_TIME}${RANDOM_SUFFIX}"
export STORAGE_ACCOUNT_NAME="${STORAGE_ACCOUNT_NAME:-capi${CREATE_TIME}${RANDOM_SUFFIX}}"
az storage account check-name --name ${STORAGE_ACCOUNT_NAME}
az storage account create -n ${STORAGE_ACCOUNT_NAME} -g ${RESOURCE_GROUP_NAME}

Expand Down

0 comments on commit 196302c

Please sign in to comment.